How do I get legal moves in Ultimate tic tac toe?

I don’t understand how this default code gets a list of legal moves (I added ‘var moves’ and condenced it)

var moves = [];
const validActionCount = parseInt(readline());
for (let i = 0; i < validActionCount; i++) {
var inputs = readline().split(' ');
const row = parseInt(inputs[0]);
const col = parseInt(inputs[1]);
moves.push([row, col]);
}

after this for loop, all legal moves for the 9x9 grid will be stored in moves.

I want to alter this to ‘test’ moves by changing the ‘input’ var, and then returning a list of legal moves AFTER that inputted move.
I am hoping I can do this instead of actually building a game logic that tells me all the possible moves.

This is my best guess at what would do what I want.

var moves = [];
while (true) {
getInputs();
console.log('3 3');
}

function getInputs(){
const validActionCount = parseInt(readline());
for (let i = 0; i < validActionCount; i++) {
var inputs = [i.toString(), i.toString()];
console.error('inputs2', inputs);
const row = parseInt(inputs[0]);
const col = parseInt(inputs[1]);
moves.push([row, col]);
}
console.error(moves);
moves = [];
}