[Question]
  [
Given a number N from 2 to 8, place any nonzero number of queens on a grid of any size so that every queen has exactly N queens (counting itself) in each of its row, column, and each diagonal.
**This challenge has a significant [restricted-time](/questions/tagged/restricted-time "show questions tagged 'restricted-time'") runtime limit.** Your code must finish all N from 2 to 8 (combined) within the 60-second timeout on [TIO](https://tio.run/#). This makes brute force unlikely to work.
Some example outputs are below. You can use this [verification script](https://tio.run/##fVXfa@NGEH62/orBeYh8URTbzXGcqR9KoXAv0VEKfRDCbKSxvURaqbsrO@7Rvz2dmZVsJ4UKLO1@@83vmXV38vvWLN9u9t53bvXw4LwqX9oD2m3dHtOybR7Uw@Pnxy/zxXwZVbiFHfpNpdWuNap28c7qKgGLh/VvtMXZKgLQWwZWwGdrfuWr1f2ioJNKNwtYQ41GBGcBWl5B@bxg1KLvrdkwQod5XsC2tbABbeDVKrPDWFTdBfF7WMxYPXNse/zAEp/CYdnW7w@Xw@E7iznruGNykaquQ1PFI1zkjF48vBaLohv4vywuHj8vv379Mpcsuq7WflNr52Pt0arnGhM47tHi4NGZRKexKssEiNcMnPU1kx9KOR/Deh0IlxN@SHwMJBfnw4NUsP8Qc6rUSGaVF/oQMXGiq63Fqi8xHl0VN4dwqGzF7E03XWs9uJPjBP26x/KF3VWkyVp1gnYLi1sn5fmrRzSOjiqYDxA2nT9Bg@gd@D1SUUylvW6NkzRShvX2FIumBAxlZCLrDdbYoCGhNTj0seubgUQJmBHJOSSn3nMTmH4zB1VTz53F9eBmOj0LLc7gteQvEkzTOw97dUBQnnpa0a41GAIjFdHkBr6rCnzLgTiqPklz7@/8HrQDq3Y7rKJJo143hJLztIob1cW0S4JRcV@M0WCETqWhgU8Qj1L3Mk10NJtdj4QIFeQD7Tkvso8m1NB9Yxj4W3fxp2CDWDzjbpGAfHlE8/eTP@ScJn2wgge2kss9kMAftseCrdXaIGsXqzJVYu4uKF6Mi2U0oSI5CbnjeiUgkhTt0GlDHd0Mfl7DjzmV@x/pqNYcpJZXDZXehi7Kbqk05Js/ttBS@9ANsFdWlaFRDZXhWmo@SFE7SnN5uiZcrTxuWMrF/N4MYQuynqbZlHtu8DDPBU61qfBV6CE1vOLc8AVyXZGLwoIj@R2pNdiBzrYlutDw2nS9j8Yk5rxInbdUqqCbAdZF80V4pU1qSY3wiUGDxssiCm705kW4l8tHiNS@EsYTWaCsxEKUm/jcaQFarIpo0lniwFMyDt/HNIUOSuBp9nYDf1q6D@DU9twgrq95jFvwSIOhXEi9o3ixxAoreD6x3qOmacBXKlN9kvF5rhU5Pkb6jP5I4wSoyn3QVCqHKSXw25Ytgao5BadhDuG7/MUBh3vfbu/56z6UOxG5kpqhdyhpn4bgprDtTcn3DXUpeRk8IgaNtzY0vqpK35ZRmmVpGtEvG98BiX6KaMdLfghMecm/KBtXQTAsg3hYpVmUjnRWGL6p4GeY8cDPhD@gWcCzYPBf) to confirm your outputs.
*N=2*
```
.OO.
O..O
O..O
.OO.
```
*N=3* (by Christian Sievers)
```
..OOO......
.O.O...O...
OO...O.....
O...O....O.
O......O..O
..O...O..O.
..O..O....O
.O...O..O..
.......OO.O
...O..O..O.
....O.O.O..
```
*N=4* (by Christian Sievers)
```
...OO..OO...
..OO....OO..
.O...OO...O.
OO........OO
O....OO....O
..O.O..O.O..
..O.O..O.O..
O....OO....O
OO........OO
.O...OO...O.
..OO....OO..
...OO..OO...
```
Your output grid can be square or rectangular. It may have empty rows and/or columns, even ones on the outside as a "margin" that makes the array bigger than necessary.
You can output as a 2D array of two distinct values of your choice, or as a string that displays as such.
For the 60-second time limit, running verification code doesn't have to happen within this time. If your language is not on TIO, you test it on any reasonable machine. On the off chance that your grids might be so big that TIO can't print them, it's allowed to run the test with storing all 7 grids instead of printing them, such as to a size-7 list where that any of them may be retrieved.
  
[Answer]
# Python 2, 141 138 bytes
[Try it online!](https://tio.run/##lVXBkuI2ED2jr@jsHGyDYTBFdjNUfMimKqk97RxSuTguSoMFiLVlR5JZyNZ@@6RbsrGZyiUn5O7X3a/7tURztcdarV7ZA@zqRooC9rqu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cWfJ5F/zKlwP78Uhq3NRiz8433KoziYz@cfRUnvhfEjRdiL0Fh75picZkmER8IhCXpV@9g0XXo2p3s27t8L6eCTP4b/kC6B1L@ZsF0yRuOhj86jPgbr678 "Python 2 – Try It Online")
```
n=input()
P=[280]
for t in[1j,9,40j-40,64j+64]:P={p+i*t for i in range(n)for p in P}
r=range(792)
print[[x+y*1jin P for x in r]for y in r]
```
Takes `n` as input and prints a list of lists of booleans.
While the grids are generated within the 60 second time limit, they are larger than TIO's 128KiB limit, so they were simplified to be printable via TIO thanks to math junkie.
I added in the verification script to the TIO link so it can also be verified within TIO.
Here's my attempt at drawing my original solution for n=3. Hopefully this helps visualize it. Replace 57 with 40 and 408 with 64 for the current solution.
[![hand_drawn_solution](https://i.stack.imgur.com/ohFQl.png)](https://i.stack.imgur.com/ohFQl.png)
[Answer]
# [Ruby](https://www.ruby-lang.org/), ~~85~~ 77 bytes
```
->n{j=n**3+n
((0...n*n).map{|i|((?.*n*n+?O)*9)[~i%n+i/n*n,j]}+[?.*j]*j)*n*$/}
```
[Try it online!](https://tio.run/##KypNqvyfZvtf1y6vOss2T0vLWDuPS0PDQE9PL08rT1MvN7GguiazRkPDXk8LKKBt76@pZakZXZepmqedqQ8U0cmKrdWOBspmxWplaQLVqOjX/jfSKy0oydew0Kyuya0pKC0pVkiLzo2t/Q8A "Ruby – Try It Online")
Similar to and inspired by cardboard\_box's answer, but rotated by 45 degrees.
Below are the first 16 lines of the output for `n=4`. It should be apparent that that within each 16x16 box, the queens form diagonal lines of 4. In between the boxes there is a single blank column. If this was not there, the diagonal lines of each `n**2` x `n**2` box would line up exactly with its neighbour when `n` is even.
There are clearly 4 queens on each horizontal row and 1 queen in each vertical column (except the blank ones.) The rest of the pattern is a repeat of the below, interspersed with `n**3+n` rows of blanks to ensure the diagonals do not clash (I could get away with just a few rows less, but the code is shorter this way.)
The output is truncated by TIO so it's only possible to get full output up to 5, but it's apparent from the way the pattern is constructed that it meets the rules. Output has been verified up to 5.
```
.............O................O................O................O...
..............O................O................O................O..
...............O................O................O................O.
................O................O................O................O
.........O................O................O................O.......
..........O................O................O................O......
...........O................O................O................O.....
............O................O................O................O....
.....O................O................O................O...........
......O................O................O................O..........
.......O................O................O................O.........
........O................O................O................O........
.O................O................O................O...............
..O................O................O................O..............
...O................O................O................O.............
....O................O................O................O............
...many blank rows, then repeat the above a total of 4 times...
```
]