Take as many counters as you like — but all from one row. Whoever is forced to take the very last counter loses.
Think in pairs. If you can leave the rows so that every counter has a partner — two rows the same length, or rows that cancel each other out — then whatever your opponent takes, you copy it on the other side.
Do that every turn and your opponent runs out first. With rows of 3, 5 and 7, the first player can always win. Try taking 1 from the row of 3 and see what happens.
Near the end it flips: once the rows are all single counters, count them. You want to leave your opponent an odd number.