Problem: cf1624_f
Difficulty: medium
Categories: search, math
Time limit: 1000 ms, memory limit: 256 MB

This problem is interactive.

We decided to play a game with you and guess the number $x$ ($1 \le x < n$), where you know the number $n$.

You can make queries like this:

* + c: this command assigns $x = x + c$ ($1 \le c < n$) and then returns you the value $\lfloor\frac{x}{n}\rfloor$ ($x$ divide by $n$ and round down).

You win if you guess the current number with no more than $10$ queries.

Interaction

The interaction begins by reading an integer $n$ ($2 < n \le 1000$), which is written in the input data on its own line.

Then you can make no more than $10$ queries. To make a query, print on a separate line:

* + c: this command will assign $x = x + c$ ($1 \le c < n$) and then print $\lfloor\frac{x}{n}\rfloor$ (divide $x$ by $n$ and round down) on a separate line.

Print the answer, like the queries, on a separate line. The answer doesn't count in number of queries. To output it, use the following format:

* ! x: the current value of $x$.

After that, your program should exit.

You have to use a flush operation right after printing each line. For example, in C++ you should use the function fflush(stdout), in Java — System.out.flush(), in Pascal — flush(output) and in Python — sys.stdout.flush().

Note that the interactor is not responsive.

Examples

Input

```
3

1
```

Output

```
+ 1

! 3
```

Input

```
5

0

0

1
```

Output

```
+ 1

+ 1

+ 1

! 5
```

Input

```
10

0

0

1

2
```

Output

```
+ 2

+ 2

+ 3

+ 8

! 20
```

Note

In the first sample initially $x = 2$. After the first query $x = 3$, $\lfloor\frac{x}{n}\rfloor = 1$.

In the second sample also initially $x = 2$. After the first query $x = 3$, $\lfloor\frac{x}{n}\rfloor = 0$. After the second query $x = 4$, $\lfloor\frac{x}{n}\rfloor = 0$. After the third query $x=5$, $\lfloor\frac{x}{n}\rfloor = 1$.

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

using namespace std;


static long long queries = 0;
static long long query_limit = 10;
static const long long HARD_CAP = 200; 


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


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

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

    
    
    int n = inf.readInt(3, 1000, "n");
    
    long long current_x = inf.readLong(1LL, (long long)n - 1, "x");

    
    cout << n << endl;

    
    log_metrics();

    
    while (true) {
        
        if (queries > HARD_CAP) {
            finish(_pe, "Hard query limit exceeded (infinite loop protection)");
        }

        string token;
        
        if (!(cin >> token)) {
            finish(_wa, "Unexpected EOF: solution terminated without outputting answer");
        }

        if (token == "!") {
            
            long long ans;
            if (!(cin >> ans)) {
                finish(_pe, "Expected integer answer after '!'");
            }

            if (ans == current_x) {
                finish(_ok, "Correct answer");
            } else {
                finish(_wa, format("Wrong answer. Expected %lld, found %lld", current_x, ans));
            }
        } else {
            
            long long c;
            bool parsed_c = false;

            
            if (token == "+" || token == "?") {
                if (cin >> c) {
                    parsed_c = true;
                } else {
                    finish(_pe, "Expected integer argument for query");
                }
            } else {
                
                try {
                    size_t idx;
                    c = stoll(token, &idx);
                    if (idx == token.size()) {
                        parsed_c = true;
                    }
                } catch (...) {
                    
                }
            }

            if (!parsed_c) {
                finish(_pe, format("Invalid token '%s'. Expected '+', '?', or a number", token.c_str()));
            }

            
            if (c < 1 || c >= n) {
                finish(_pe, format("Invalid query argument c=%lld. Constraint: 1 <= c < n (%d)", c, n));
            }

            
            queries++;
            current_x += c;
            long long response = current_x / n;

            
            cout << response << endl;
            
            
            if (queries % 5 == 0) {
                log_metrics();
            }
        }
    }

    return 0;
}


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

using namespace std;


ofstream tout_stream;


static long long queries = 0;
static long long query_limit = 10; 
static int hard_cap = 200;         


static void log_metrics() {
    if (tout_stream.is_open()) {
        tout_stream << "queries=" << queries << endl;
        tout_stream << "query_limit=" << query_limit << endl;
        tout_stream.flush();
    }
}


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

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

    
    
    
    tout_stream.open(argv[2]);

    
    atexit(log_metrics);

    
    int n = inf.readInt();
    
    
    cout << n << endl;

    
    log_metrics();

    
    
    
    long long low = 1;
    long long high = n - 1;
    long long current_adder = 0; 

    
    while (true) {
        string token;
        
        if (!(cin >> token)) {
            finish(_pe, "Unexpected EOF: expected '+' or '!'");
        }

        if (token == "!") {
            long long ans;
            if (!(cin >> ans)) {
                finish(_pe, "Expected integer after '!'");
            }

            
            
            

            
            
            if (low < high) {
                finish(_wa, format("Solution not unique. Feasible initial x0 in [%lld, %lld], guessed current %lld",
                                   low, high, ans));
            }

            
            long long expected = low + current_adder;
            if (ans == expected) {
                finish(_ok, "Correct");
            } else {
                finish(_wa, format("Expected %lld, found %lld", expected, ans));
            }

        } else if (token == "+") {
            long long c;
            if (!(cin >> c)) {
                finish(_pe, "Expected integer after '+'");
            }

            
            if (c < 1 || c >= n) {
                finish(_pe, format("Increment c=%lld out of range [1, %d)", c, n));
            }

            
            queries++;
            log_metrics();

            
            if (queries > hard_cap) {
                finish(_pe, "Too many queries (hard cap exceeded)");
            }

            current_adder += c;

            
            
            
            
            
            long long r_min = (low + current_adder) / n;
            long long r_max = (high + current_adder) / n;
            long long response = -1;

            if (r_min == r_max) {
                
                response = r_min;
            } else {
                
                
                
                
                long long boundary = r_max * n - current_adder;

                
                
                long long size_min = max(0LL, (boundary - 1) - low + 1);
                long long size_max = max(0LL, high - boundary + 1);

                
                if (size_min >= size_max) {
                    response = r_min;
                    high = boundary - 1;
                } else {
                    response = r_max;
                    low = boundary;
                }
            }

            
            if (low > high) {
                finish(_fail, "Interactor internal error: feasible set became empty");
            }

            cout << response << endl;

        } else {
            finish(_pe, "Invalid token '" + token + "'");
        }
    }

    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");
    int n = opt<int>("n", -1);
    int x = opt<int>("x", -1);

    
    int seed_val = atoi(argv[1]);

    
    if (n == -1) {
        if (seed_val == 1) {
            n = 3;                  
        } else if (seed_val == 2) {
            n = 1000;               
        } else if (seed_val == 3) {
            n = 1000;               
        } else if (seed_val == 4) {
            n = 4;                  
        } else if (seed_val == 5) {
            n = 5;                  
        } else if (seed_val == 6) {
            n = 512;                
        } else if (seed_val == 7) {
            n = 997;                
        } else if (seed_val >= 8 && seed_val <= 20) {
            
            n = rnd.next(900, 1000);
        } else {
            
            n = rnd.next(3, 1000);
        }
    }

    
    if (n < 3) n = 3;
    if (n > 1000) n = 1000;

    
    cout << n << endl;

    
    if (mode == "non") {
        
        if (x == -1) {
            if (seed_val == 1) {
                x = 1;              
            } else if (seed_val == 2) {
                x = n - 1;          
            } else if (seed_val == 3) {
                x = 1;              
            } else {
                
                x = rnd.next(1, n - 1);
            }
        }

        
        if (x < 1) x = 1;
        if (x >= n) x = n - 1;

        cout << x << endl;
    } 
    
    

    return 0;
}