import java.util.*;
import java.io.*;

public class TestGen implements Runnable {
    private ArrayList<String> data;
    private int done = 0;

    private final int MAXN = (int) 1e5;
    private final long LARGE = (long) 1e13;
    private final long SMALL = (long) 1e6;

    private Random rnd;

    private void print() throws IOException {
        String filename = "" + (done + 1);
        if (done < 9) {
            filename = "0" + filename;
        }
        PrintWriter out = new PrintWriter(new File("..\\tests\\" + filename));
        for (int i = 0; i < data.size(); i++) {
            out.println(data.get(i));
        }
        out.close();
        done++;
        System.out.println(done);
        data.clear();
    }

    private void genSample() throws IOException {
        data.add("10");
        data.add("+ 1");
        data.add("+ 4");
        data.add("+ 3");
        data.add("+ 4");
        data.add("?");
        data.add("-");
        data.add("-");
        data.add("?");
        data.add("-");
        data.add("?");
        print();
    }

    private void genAddAsk(int length, long maxVal, int delta) throws IOException {
        int n = length / 2 / (delta + 1) * (delta + 1);
        int left = length - n;
        data.add(length + "");
        makeSection("+ ", n, maxVal, delta, true);
        makeSection("?", left);
        print();
    }

    private void genAddRemAskOnce(int length, long maxVal, int delta) throws IOException {
        int add = (length - 1) / (delta + 1) * (delta + 1);
        int left = length - 1 - add;
        data.add(length + "");
        makeSection("+ ", add, maxVal, delta, true);
        makeSection("-", left);
        makeSection("?", 1);
        print();
    }

    private int nextInt(int low, int high) {
        return Math.abs(rnd.nextInt()) % (high - low + 1) + low;
    }

    private char nextChar() {
        int cd = nextInt(0, 3);
        if (cd == 0) {
            return '-';
        } else if (cd == 1) {
            return '?';
        } else {
            return '+';
        }
    }

    private void genRandPattern(int length, long maxVal, int delta) throws IOException {
        int pLength = nextInt(1, length);
        char[] pattern = new char[pLength];
        for (int i = 0; i < pLength; i++) {
            pattern[i] = nextChar();
        }
        int balance = 0;
        for (int i = 0; i < pLength; i++) {
            if (balance == 0 && pattern[i] != '+') {
                pattern[i] = '+';
            }
            if (pattern[i] == '+') {
                balance++;
            } else if (pattern[i] == '-') {
                balance--;
            }
        }
        String pt = "";
        for (int i = 0; i < pattern.length; i++) {
            pt += pattern[i];
        }
        genPattern(length, maxVal, delta, pt);
    }

    private void genPattern(int length, long maxVal, int delta, String pattern) throws IOException {
        int pLength = pattern.length();
        ArrayList<String> p = new ArrayList<String>();
        for (int i = 0; i < pLength; i++) {
            if (pattern.charAt(i) == '+') {
                p.add("+ ");
            } else {
                p.add("" + pattern.charAt(i));
            }
        }
        data.add("" + length);
        makeSection(p, length, maxVal, delta);
        print();
    }


    private void makeSection(String code, int length) {
        for (int i = 0; i < length; i++) {
            data.add(code);
        }
    }

    private void makeSection(ArrayList<String> code, int length, long maxVal, int delta) {
        int cl = length;
        int i = 0;
        while (cl > 0) {
            for (int j = 0; j < code.size() && cl > 0; j++) {
                if (code.get(j).charAt(0) == '+') {
                    data.add(code.get(j) + (maxVal - i));
                    i++;
                    if (i == delta + 1) {
                        i = 0;
                    }
                } else {
                    data.add(code.get(j));
                }
                cl--;
            }
        }
    }

    private void makeSection(String code, int length, long maxVal, int delta, boolean valid) {
//        if (valid && length % (delta + 1) != 0) {
//
//            throw new RuntimeException("ERROR: section length is incorrect " + length + " " + (delta + 1));
//        }
        int cl = length;
        while (cl > 0) {
            for (int i = 0; i < delta + 1 && cl > 0; i++) {
                data.add(code + (maxVal - i));
                cl--;
            }
        }
    }


    public void run() {
        try {
            File testDir = new File("..\\tests");
            if (!testDir.exists()) {
                testDir.mkdir();
            }

            rnd = new Random(94756);
            data = new ArrayList<String>();

            genSample();

            genAddAsk(MAXN, SMALL, 0);
            genAddAsk(MAXN, SMALL, 100);
            genAddAsk(MAXN, SMALL, (int) 1e5 / 5);

            genAddRemAskOnce(MAXN, SMALL, 0);
            genAddRemAskOnce(MAXN, SMALL, 100);
            genAddRemAskOnce(MAXN, SMALL, (int) 1e5 / 5);


            genPattern(MAXN, SMALL, 100, "++?-");
            genPattern(MAXN, SMALL, 100, "++-?");
            genPattern(MAXN, SMALL, 100, "+++?-?");

            for (int i = 0; i < 8; i++) {
                genRandPattern(MAXN, SMALL, nextInt(10, 1000));
            }

            genAddAsk(MAXN, LARGE, 0);
            genAddAsk(MAXN, LARGE, 100);
            genAddAsk(MAXN, LARGE, (int) 1e5 / 5);

            genPattern(MAXN, LARGE, 100, "++?-");
            genPattern(MAXN, LARGE, 100, "++-?");
            genPattern(MAXN, LARGE, 100, "+++?-?");


            genAddRemAskOnce(MAXN, LARGE, 0);
            genAddRemAskOnce(MAXN, LARGE, 100);
            genAddRemAskOnce(MAXN, SMALL, (int) 1e5 / 5);

            for (int i = 0; i < 3; i++) {
                genRandPattern(MAXN, LARGE, nextInt(10, 1000));
            }


        } catch (IOException e) {
            e.printStackTrace();
            System.exit(1);
        }
    }

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













