A Tic-Tac-Toe board is given after some moves are played. Find out if the given board is valid, i.e., is it possible to reach this board position after some moves or not.

Note that every arbitrary filled grid of 9 spaces isn’t valid e.g. a grid filled with 3 X and 6 O isn’t valid situation because each player needs to take alternate turns.

**Note : **The game starts with X

**Input:**

The first line of input contains an integer T denoting the number of test cases.

The first line of each test case is given as a 1D array of size 9.

**Output:**

Print Valid if board is valid, else Invalid.

**Constraints:**

1 ≤ T ≤ 100

**Example:**

**Input:**

2

X X O O X O O O O

X X O O O X X O X

**Output:**

Invalid

Valid

just_kiddin | 61 |

Devina Mohan | 59 |

BackSlashNull | 53 |

PALINDROME | 52 |

Sangeeta S | 52 |

gameghost07 | 488 |

xyz2017 | 486 |

N NAGA SAI KRISHNA | 445 |

Divyasri | 426 |

Anshu Ahirwar | 424 |

akhayrutdinov | 3391 |

sanjay05 | 3239 |

Jasleen Kaur 2 | 2012 |

Elite Coder | 1805 |

Michael Riegger | 1791 |