Chocolate Bar Game
时间限制:C/C++/Rust/Pascal 1秒,其他语言2秒
空间限制:C/C++/Rust/Pascal 256 M,其他语言512 M
64bit IO Format: %lld

题目描述

Dia and Ruby take turns playing a game using an n x n square chocolate bar. Each turn, the current player must do one of the following (Ruby will go first):

1. Select a prime number p that has not been selected by any player in the previous rounds. Then, choose a p x p square that does not contain any empty squares on the chocolate bar and eat up every chocolate square within the p x p square. 
2. Eat an arbitrary 1 x 1 chocolate square on the bar. 

The player who eats up the last chocolate square wins. Initially, some squares on the chocolate bar are already eaten. If both players play optimally, who will win the game? Note: “optimally” means if any player has a strategy to win no matter how their opponent responds, they will take that move – optimizing their chance of winning. 

输入描述:

Input consists of multiple lines. The first line contains a single integer, n, (1 <= n <= 2000) whichgives the dimensions of the chocolate bar and indicates there are n lines of data that follow thatdescribe the chocolate bar.

Each line contains n characters consisting of X (indicating an empty square) or (indicating achocolate square). 

输出描述:

The output line consists of the word RUBY if Ruby is the winner or DIA if Dia is the winner. 
示例1

输入

复制
4
----
---X
----
XXXX

输出

复制
RUBY