/**
 * Created by GShark on 10.11.2014.
 */
import java.io.*;
import java.util.*;

public class TestGen {
    public static void main(String[] args) throws IOException {
        new TestGen().run();
    }

    BufferedReader br;
    StringTokenizer in;
    PrintWriter out;

    public String nextToken() throws IOException {
        while (in == null || !in.hasMoreTokens()) {
            in = new StringTokenizer(br.readLine());
        }
        return in.nextToken();
    }

    public int nextInt() throws IOException {
        return Integer.parseInt(nextToken());
    }

    public long nextLong() throws IOException {
        return Long.parseLong(nextToken());
    }

    public double nextDouble() throws IOException {
        return Double.parseDouble(nextToken());
    }

    int tNumber;
    Random rnd;
    final int MAXN = 1_000_000;

    int rand(int n) {
        return rnd.nextInt(n);
    }

    long rand(long n) {
        long bits, val;
        do {
            bits = (rnd.nextLong() << 1) >>> 1;
            val = bits % n;
        } while (bits - val + (n - 1) < 0L);
        return val;
    }

    String randDigit() {
        char c = (char)(rand(10) + '0');
        String s = "";
        s += c;
        return s;
    }

    String randOperator() {
        int tmp = rand(4);
        if (tmp % 2 == 0) {
            return "*";
        } else if (tmp == 1) {
            return "+";
        } else {
            return "-";
        }
    }

    String randVariable() {
        int tmp = rand(2);
        if (tmp == 0) {
            return "x";
        } else {
            return "y";
        }
    }

    void print(String s, int x, int y) throws IOException {
        System.err.println(tNumber);
        if (tNumber < 10) {
            out = new PrintWriter("../tests/0" + tNumber);
        } else {
            out = new PrintWriter("../tests/" + tNumber);
        }
        tNumber++;
        out.println(s);
        if (x == 0) {
            out.println("Even");
        } else {
            out.println("Odd");
        }
        if (y == 0) {
            out.println("Even");
        } else {
            out.println("Odd");
        }
        out.close();
    }

    // here starts gens

    void genSample1() throws IOException {
        print("1+23+x+456*y-7", 1, 0);
    }

    void genSample2() throws IOException {
        print("x*x*x*y-x", 1, 0);
    }

    void genSimples() throws IOException {
        print("2+2", 0, 0);
        print("7*x", 0, 1);
        print("x-y*2", 1, 1);
        print("0", 1, 1);
        print("x*x+y*y+5*5", 1, 0);
        print("x*y*1024*1024*1024*1024-1", 1, 1);
        print("123456789999999", 1, 1);
    }

    String genRandNumber(int n) {
        StringBuilder s = new StringBuilder("");
        if (n == 1) {
            s.append((randDigit()));
        } else {
            String c = randDigit();
            while (c.equals("0")) {
                c = randDigit();
            }
            s.append(c);
            for (int i = 1; i < n; i++) {
                s.append(randDigit());
            }
        }
        return s.toString();
    }

    void genRand(int n) throws IOException {
        StringBuilder s = new StringBuilder("");
        boolean isOp = true;
        while (s.length() < n) {
            if (isOp) {
                if (rand(2) == 0) {
                    s.append(randVariable());
                } else {
                    s.append(genRandNumber(rand(n - s.length()) + 1));
                }
                isOp = false;
            } else {
                if (s.length() + 1 < n) {
                    s.append(randOperator());
                    isOp = true;
                } else {
                    break;
                }
            }
        }
        print(s.toString(), rand(2), rand(2));
    }

    void genRand1(int n) throws IOException {
        StringBuilder s = new StringBuilder("");
        boolean isOp = true;
        while (s.length() < n) {
            if (isOp) {
                if (rand(2) == 0) {
                    s.append(randVariable());
                } else {
                    s.append(genRandNumber(Math.min(rand(15) + 1, (n - s.length()))));
                }
                isOp = false;
            } else {
                if (s.length() + 1 < n) {
                    s.append(randOperator());
                    isOp = true;
                } else {
                    break;
                }
            }
        }
        print(s.toString(), rand(2), rand(2));
    }

    void genEvalKiller1() throws IOException {
        StringBuilder s = new StringBuilder(genRandNumber(MAXN / 10));
        while (s.length() + MAXN / 10 + 1 < MAXN) {
            s.append("*" + genRandNumber(MAXN / 10));
        }
        print(s.toString(), rand(2), rand(2));
    }

    void genEvalKiller2() throws IOException {
        StringBuilder s = new StringBuilder("3");
        while (s.length() + 2 < MAXN) {
            s.append("*" + 3);
        }
        print(s.toString(), rand(2), rand(2));
    }

    void genVar() throws IOException {
        StringBuilder s = new StringBuilder("x");
        //String s = "x";
        while (s.length() + 2 < MAXN) {
            s.append(randOperator() + randVariable());
        }
        print(s.toString(), rand(2), rand(2));
    }


    //the end of the gens

    public void generate() throws IOException {
        new File("../tests").mkdir();
        tNumber = 1;
        rnd = new Random(388282447);
        genSample1();
        genSample2();
        genSimples();
        for (int i = 1; i <= 20; i++) {
            genRand(i * 5000);
            genRand1(i * 5000);
        }
        System.out.println("BIG TESTS");
        genVar();
        genVar();
        genEvalKiller1();
        genEvalKiller2();
    }

    public void run() throws IOException {
        Locale.setDefault(Locale.US);
        generate();
    }
}
