import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Random;
import java.util.Scanner;

// sample random-walk AI
public class SampleAI {
	private static Random random;
	private static Scanner scanner;
	private static PrintWriter writer;
	
	private static int T;
	private static int L[4];
	private static int B[40][40];
	private static int R[4];
	private static int C[4];
	private static String D[4];
	private static String O[4];
	
	private static int maxTurn = 100; // temporary magic number
	private static String commands = "URDLAN";

	public static void main(String[] args) {
		random = new Random();
		scanner = new Scanner(System.in);
		writer = new PrintWriter(System.out, true);
		writer.println("Ready");
		writer.flush;

		// TODO: Modify the exit condition
		for(int t = 0; t < maxTurn; t++) {
			readData();
			writeCommand();
		}
		
		scanner.close();
		writer.close();
	}
	
	private static void readData() {
		T = scanner.nextInt();
		for(int i = 0; i < 4; i++) {
			L[i] = scanner.nextInt();
		}
		for(int i = 0; i < 40; i++) {
			for(int j = 0; j < 40; j++) {
				B[i][j] = scanner.nextInt();
			}
		}
		for(int i = 0; i < 4; i++) {
			R[i] = scanner.nextInt();
			C[i] = scanner.nextInt();
			D[i] = scanner.next();
		}
		for(int i = 0; i < 4; i++) {
			O[i] = scanner.next();
		}
	}
	
	private static void writeCommand() {
		writer.println(commands.charAt(random.nextInt(commands.length())));
		writer.flush();
	}
}
@@ -189,18 +189,16 @@
 s Sample
-AI
  %7B%0D%0A%09pri
@@ -295,24 +295,55 @@
 writer;%0D%0A%09%0D%0A
+%09private static int playerId;%0D%0A
 %09private sta
@@ -376,17 +376,16 @@
 c int L%5B
-4
 %5D;%0D%0A%09pri
@@ -406,14 +406,10 @@
 t B%5B
-40%5D%5B40
+%5D%5B
 %5D;%0D%0A
@@ -430,17 +430,16 @@
 c int R%5B
-4
 %5D;%0D%0A%09pri
@@ -456,17 +456,16 @@
 c int C%5B
-4
 %5D;%0D%0A%09pri
@@ -485,17 +485,16 @@
 tring D%5B
-4
 %5D;%0D%0A%09pri
@@ -518,76 +518,104 @@
 g O%5B
-4
 %5D;%0D%0A%09
-%0D%0A%09private static int maxTurn = 100; // temporary magic number
+private static String EOD;%0D%0A%09%0D%0A%09private static int myLife;%0D%0A%09private static int enemyLives;
 %0D%0A%09p
@@ -659,16 +659,19 @@
 AN%22;%0D%0A%0D%0A
+%09%0D%0A
 %09public 
@@ -705,16 +705,143 @@
 rgs) %7B%0D%0A
+%09%09L = new int%5B4%5D;%0D%0A%09%09B = new int%5B40%5D%5B40%5D;%0D%0A%09%09R = new int%5B4%5D;%0D%0A%09%09C = new int%5B4%5D;%0D%0A%09%09D = new String%5B4%5D;%0D%0A%09%09O = new String%5B4%5D;%0D%0A%0D%0A
 %09%09random
@@ -988,61 +988,110 @@
 lush
+()
 ;%0D%0A%0D%0A%09%09
-// TODO: Modify the exit condition
+while(true) %7B%0D%0A%09%09%09readData();%0D%0A%09%09%09%0D%0A%09%09%09myLife = L%5BplayerId%5D;%0D%0A%09%09%09enemyLives = 0;
 %0D%0A%09%09
+%09
 for(int 
 t = 
@@ -1090,39 +1090,138 @@
 int 
-t
+i
  = 0; 
-t %3C maxTurn; t++
+i %3C 4; i++) %7B%0D%0A%09%09%09%09if(i != playerId) %7B%0D%0A%09%09%09%09%09enemyLives += L%5Bi%5D;%0D%0A%09%09%09%09%7D%0D%0A%09%09%09%7D%0D%0A%09%09%09if(myLife == 0 %7C%7C enemyLives == 0
 ) %7B%0D%0A%09%09%09
 read
@@ -1212,35 +1212,42 @@
 == 0) %7B%0D%0A%09%09%09
+%09b
 rea
-dData();
+k;%0D%0A%09%09%09%7D%0D%0A%09%09%09
 %0D%0A%09%09%09writeCo
@@ -1346,16 +1346,49 @@
 ta() %7B%0D%0A
+%09%09playerId = scanner.nextInt();%0D%0A
 %09%09T = sc
@@ -1772,16 +1772,41 @@
 ;%0D%0A%09%09%7D%0D%0A
+%09%09EOD = scanner.next();%0D%0A
 %09%7D%0D%0A%09%0D%0A%09

Update the sample Java AI