Problem: cf1840_g1
Difficulty: easy
Categories: search, math
Time limit: 2000 ms, memory limit: 256 MB

The only difference between easy and hard versions is the maximum number of queries. In this version, you are allowed to ask at most $2023$ queries.

This is an interactive problem.

You are playing a game. The circle is divided into $n$ sectors, sectors are numbered from $1$ to $n$ in some order. You are in the adjacent room and do not know either the number of sectors or their numbers. There is also an arrow that initially points to some sector. Initially, the host tells you the number of the sector to which the arrow points. After that, you can ask the host to move the arrow $k$ sectors counterclockwise or clockwise at most $2023$ times. And each time you are told the number of the sector to which the arrow points.

Your task is to determine the integer $n$ — the number of sectors in at most $2023$ queries.

It is guaranteed that $1 \le n \le 10^6$.

Input

The input consists of a single integer $x$ ($1 \le x \le n$) — the number of the initial sector.

Output

After you determine the integer $n$ — the number of sectors, you should output "! n" ($1 \le n \le 10^6$). After that the program should immediately terminate.

Note that, printing the answer does not count as a query.

It is guaranteed that the integer $n$ and the numbers of the sectors are fixed initially and will not be changed by the jury program depending on the queries.

Interaction

After reading the description of the input, you may ask queries. Queries can be of two types:

1. "+ k" ($0 \le k \le 10^9$) — ask to move the arrow $k$ sectors clockwise.
2. "- k" ($0 \le k \le 10^9$) — ask to move the arrow $k$ sectors counterclockwise.

After each query, you should read an integer $x$ ($1 \le x \le n$) — the number of the current sector to which the arrow points.

You are allowed to make at most $2023$ queries in total.

If you make too many queries, you will get Wrong answer.

After printing a query or the answer, do not forget to output a the end of line and flush the output. Otherwise, you will get Idleness limit exceeded. To do this, use:

* fflush(stdout) or cout.flush() in C++;
* System.out.flush() in Java;
* flush(output) in Pascal;
* stdout.flush() in Python;
* see the documentation for other languages.

Example

Input

```
1

5

6

7

2

10

9

8

4

3

1
```

Output

```
+ 1

+ 1

+ 1

+ 1

+ 1

+ 1

+ 1

+ 1

+ 1

+ 1

! 10
```

Note

Non-adaptive interactor (C++):
#include "testlib.h"
#include <bits/stdc++.h>

using namespace std;


static long long queries = 0;
static const long long query_limit = 2023; 
static bool finished = false;


static void log_metrics() {
    if (finished) return;
    
    
    try {
        tout << "queries=" << queries << endl;
        tout << "query_limit=" << query_limit << endl;
    } catch (...) {}
}


template <typename... Args>
void finish(TResult verdict, const char* fmt, Args... args) {
    log_metrics();
    finished = true;
    quitf(verdict, fmt, args...);
}

int main(int argc, char** argv) {
    
    registerInteraction(argc, argv);
    atexit(log_metrics);

    
    
    int n = inf.readInt(1, 1000000, "n");
    int start_pos = inf.readInt(0, n - 1, "start_pos");
    vector<int> p(n);
    for (int i = 0; i < n; i++) {
        p[i] = inf.readInt(1, n, format("p[%d]", i));
    }

    
    cout << p[start_pos] << endl;

    
    int current_pos = start_pos;
    long long hard_cap = 20000; 

    while (true) {
        
        if (queries > hard_cap) {
            finish(_pe, "Hard query limit exceeded (%lld)", hard_cap);
        }

        
        string token;
        if (!(cin >> token)) {
            finish(_pe, "Unexpected EOF (expected query or answer)");
        }

        
        if (token == "!") {
            int ans;
            if (!(cin >> ans)) {
                finish(_pe, "Unexpected EOF reading answer value");
            }
            if (ans == n) {
                finish(_ok, "Correct! n=%d. Queries: %lld", n, queries);
            } else {
                finish(_wa, "Wrong answer. Expected n=%d, found %d", n, ans);
            }
        }

        
        string op = token;
        if (token == "?") {
            if (!(cin >> op)) {
                finish(_pe, "Unexpected EOF after '?'");
            }
        }

        if (op != "+" && op != "-") {
            finish(_pe, "Invalid query operator: '%s'. Expected '+', '-', or '!'", op.c_str());
        }

        long long k;
        if (!(cin >> k)) {
            finish(_pe, "Unexpected EOF reading k");
        }

        
        if (k < 0 || k > 1000000000LL) {
            finish(_pe, "k out of range [0, 10^9]: %lld", k);
        }

        
        queries++;
        
        
        if (queries % 10 == 0) {
            tout << "queries=" << queries << endl;
            tout << "query_limit=" << query_limit << endl;
        }

        
        long long shift = k % n;
        if (op == "+") {
            current_pos = (current_pos + shift) % n;
        } else {
            
            current_pos = (current_pos - shift + n) % n;
        }

        
        cout << p[current_pos] << endl;
    }

    return 0;
}


Adaptive interactor (C++):
#include "testlib.h"
#include <bits/stdc++.h>

using namespace std;


static long long queries = 0;

static long long query_limit = 2023;






void log_metrics() {
    try {
        tout << "queries=" << queries << endl;
        tout << "query_limit=" << query_limit << endl;
    } catch (...) {
        
    }
}


void finish(TResult verdict, const string& msg) {
    log_metrics();
    quitf(verdict, "%s", msg.c_str());
}

int main(int argc, char* argv[]) {
    
    
    registerInteraction(argc, argv);
    
    
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    
    atexit(log_metrics);

    
    
    int n = inf.readInt();
    
    int start_pos = 0;
    vector<int> p;

    
    
    
    inf.skipBlanks();
    if (!inf.eof()) {
        
        start_pos = inf.readInt();
        p.resize(n);
        for (int i = 0; i < n; i++) {
            p[i] = inf.readInt();
        }
    } else {
        
        
        p = rnd.perm(n, 1); 
        start_pos = rnd.next(0, n - 1);
    }

    
    int curr = start_pos;

    
    long long hard_cap = 200000;

    
    cout << p[curr] << endl;

    
    log_metrics();

    
    while (true) {
        
        if (queries > hard_cap) {
            finish(_pe, "Hard query limit exceeded.");
        }

        string type;
        if (!(cin >> type)) {
            finish(_pe, "Unexpected end of input from contestant.");
        }

        if (type == "!") {
            int ans;
            if (!(cin >> ans)) {
                finish(_pe, "Expected integer after '!'");
            }
            
            
            if (ans == n) {
                finish(_ok, format("Correct! n=%d found in %lld queries.", n, queries));
            } else {
                finish(_wa, format("Wrong answer. Expected n=%d, found %d.", n, ans));
            }
        } 
        else if (type == "+" || type == "-") {
            long long k;
            if (!(cin >> k)) {
                finish(_pe, format("Expected integer after '%s'", type.c_str()));
            }

            
            if (k < 0 || k > 1000000000LL) {
                finish(_pe, format("Argument k=%lld out of range [0, 10^9]", k));
            }

            
            queries++;

            
            if (type == "+") {
                curr = (int)((curr + (k % n)) % n);
            } else {
                long long rem = k % n;
                curr = (int)((curr - rem + n) % n);
            }

            
            cout << p[curr] << endl;
            
            
            log_metrics();
        } 
        else {
            finish(_pe, format("Unknown query type '%s'", type.c_str()));
        }
    }

    return 0;
}


Test generator (C++):
#include "testlib.h"
#include <bits/stdc++.h>

using namespace std;

int main(int argc, char* argv[]) {
    registerGen(argc, argv, 1);

    
    string mode = opt<string>("mode", "non");
    
    
    long long seed = (argc > 1) ? atoll(argv[1]) : 0;

    int n;
    
    if (seed == 1) {
        n = 1; 
    } else if (seed == 2) {
        n = 1000000; 
    } else if (seed == 3) {
        n = 2023; 
    } else if (seed == 4) {
        n = 999983; 
    } else {
        
        int type = rnd.next(1, 100);
        if (type <= 5) {
            
            n = rnd.next(1, 50);
        } else if (type <= 15) {
            
            n = rnd.next(1800, 2200);
        } else if (type <= 60) {
            
            n = rnd.next(500000, 1000000);
        } else {
            
            n = rnd.next(1, 1000000);
        }
    }

    if (mode == "non") {
        
        
        
        
        
        cout << n << "\n";

        int start_pos = rnd.next(0, n - 1);
        cout << start_pos << "\n";

        
        vector<int> p = rnd.perm(n, 1);
        for (int i = 0; i < n; i++) {
            cout << p[i] << (i == n - 1 ? "" : " ");
        }
        cout << "\n";

    } else {
        
        
        
        cout << n << "\n";
    }

    return 0;
}