Problem: cf1375_f
Difficulty: hard
Categories: game, math
Time limit: 1000 ms, memory limit: 256 MB

This is an interactive problem.

Anton and Harris are playing a game to decide which of them is the king of problemsetting.

There are three piles of stones, initially containing $a$, $b$, and $c$ stones, where $a$, $b$, and $c$ are distinct positive integers. On each turn of the game, the following sequence of events takes place:

* The first player chooses a positive integer $y$ and provides it to the second player.
* The second player adds $y$ stones to one of the piles, with the condition that he cannot choose the same pile in two consecutive turns.

The second player loses if, at any point, two of the piles contain the same number of stones. The first player loses if $1000$ turns have passed without the second player losing.

Feeling confident in his skills, Anton decided to let Harris choose whether he wants to go first or second. Help Harris defeat Anton and become the king of problemsetting!

Input

The first line of input contains three distinct positive integers $a$, $b$, and $c$ ($1 \le a, b, c \le 10^9$)  — the initial number of stones in piles $1$, $2$, and $3$ respectively.

Interaction

The interaction begins by reading the integers $a$, $b$ and $c$.

After reading the integers, print a single line containing either "First" or "Second", denoting who you want to play as (as first or second correspondently).

On each turn, the first player (either you or the judge) must print a positive integer $y$ ($1 \le y \le 10^{12}$).

Then, the second player must print $1$, $2$, or $3$, indicating which pile should have $y$ stones added to it. From the second turn onwards, the pile that the second player chooses must be different from the pile that they chose on the previous turn.

If you are playing as Second and complete $1000$ turns without losing, or if you are playing as First and the judge has determined that it cannot make a move without losing, the interactor will print $0$ and will finish interaction. This means that your program is correct for this test case, and you should exit immediately.

If you are playing as First and complete $1000$ turns without winning, or if you are playing as Second and print a move that makes two piles have the same number of stones, or if you output an invalid move as either player, the interactor will print $-1$ and will finish interaction. You will receive a Wrong Answer verdict. Make sure to exit immediately to avoid getting other verdicts.

After printing something do not forget to output 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 documentation for other languages.

Example

Input

```
5 2 6

3

0
```

Output

```
First
2

3
```

Note

In the sample input, the piles initially have $5$, $2$, and $6$ stones. Harris decides to go first and provides the number $2$ to Anton. Anton adds $2$ stones to the third pile, which results in $5$, $2$, and $8$.

In the next turn, Harris chooses $3$. Note that Anton cannot add the stones to the third pile since he chose the third pile in the previous turn. Anton realizes that he has no valid moves left and reluctantly recognizes Harris as the king.

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


static long long queries = 0;
static long long query_limit = 1000;

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);

    
    long long a = inf.readInt();
    long long b = inf.readInt();
    long long c = inf.readInt();

    
    cout << a << " " << b << " " << c << endl;

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

    vector<long long> p = {0, a, b, c}; 
    int last_pile = 0;

    if (role == "First") {
        
        
        
        while (queries < query_limit) {
            queries++;
            long long y;
            if (!(cin >> y)) {
                finish(_pe, "Unexpected EOF or invalid format reading y");
            }
            
            
            if (y < 1 || y > 1000000000000LL) {
                 cout << -1 << endl;
                 finish(_wa, "y out of range");
            }

            
            vector<int> candidates;
            for (int i = 1; i <= 3; i++) {
                if (i != last_pile) candidates.push_back(i);
            }

            
            vector<int> safe_moves;
            for (int idx : candidates) {
                long long new_val = p[idx] + y;
                bool eq = false;
                for (int other = 1; other <= 3; other++) {
                    if (idx != other && p[other] == new_val) eq = true;
                }
                if (!eq) safe_moves.push_back(idx);
            }

            if (safe_moves.empty()) {
                
                cout << 0 << endl;
                finish(_ok, "Contestant forced equality");
            } else {
                
                int move = safe_moves[0];
                p[move] += y;
                last_pile = move;
                cout << move << endl;
            }
        }
        
        cout << -1 << endl;
        finish(_wa, "Query limit exceeded without forcing equality");

    } else if (role == "Second") {
        
        
        
        while (queries < query_limit) {
            queries++;
            long long y_out = 0;

            
            
            
            
            if (queries == 1) {
                y_out = 1000000000LL; 
            } else {
                vector<long long> vals;
                for(int i=1; i<=3; ++i) vals.push_back(p[i]);
                sort(vals.begin(), vals.end());
                long long x = vals[0];
                long long yy = vals[1];
                long long z = vals[2];

                if (queries == 2) {
                    y_out = 2 * z - x - yy;
                } else if (queries == 3) {
                    y_out = z - yy;
                } else {
                    y_out = 1; 
                }
            }

            cout << y_out << endl;

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

            if (k < 1 || k > 3) {
                cout << -1 << endl;
                finish(_wa, "Invalid pile index (range)");
            }
            if (k == last_pile) {
                cout << -1 << endl;
                finish(_wa, "Invalid pile index (same as previous)");
            }

            p[k] += y_out;
            last_pile = k;

            
            if (p[1] == p[2] || p[1] == p[3] || p[2] == p[3]) {
                cout << -1 << endl;
                finish(_wa, "Contestant move created equality");
            }
        }
        
        cout << 0 << endl;
        finish(_ok, "Contestant survived 1000 turns");

    } else {
        finish(_pe, "Invalid role (expected First or Second)");
    }

    return 0;
}


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

using namespace std;


static int queries = 0;
static const int query_limit = 1000;
static long long p[4];      
static int last_idx = 0;    



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






void finish(TResult verdict, const string& msg, int exit_code_to_contestant = -2) {
    if (exit_code_to_contestant == 0) {
        cout << 0 << endl;
    } else if (exit_code_to_contestant == -1) {
        cout << -1 << endl;
    }
    log_metrics();
    quitf(verdict, "%s", msg.c_str());
}


bool check_collision() {
    return (p[1] == p[2] || p[1] == p[3] || p[2] == p[3]);
}



long long get_win_move() {
    
    vector<pair<long long, int>> v;
    for(int i=1; i<=3; ++i) v.push_back({p[i], i});
    sort(v.begin(), v.end());

    long long a = v[0].first;
    long long b = v[1].first;
    long long c = v[2].first;
    int max_idx = v[2].second;

    
    bool is_ap = (b - a == c - b);

    
    
    
    
    
    if (is_ap && last_idx == max_idx) {
        return b - a;
    } else {
        
        
        
        return 2 * c - b - a;
    }
}

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

    
    p[1] = inf.readLong();
    p[2] = inf.readLong();
    p[3] = inf.readLong();

    
    cout << p[1] << " " << p[2] << " " << p[3] << endl;
    
    
    log_metrics();

    
    string role;
    if (!(cin >> role)) finish(_wa, "Unexpected EOF reading role", -1);
    
    bool human_is_first;
    if (role == "First") human_is_first = true;
    else if (role == "Second") human_is_first = false;
    else finish(_wa, "Invalid role: " + role, -1);

    
    for (queries = 1; queries <= query_limit; queries++) {
        log_metrics(); 

        if (human_is_first) {
            
            long long y;
            if (!(cin >> y)) finish(_wa, "Unexpected EOF reading y", -1);
            if (y < 1 || y > 1000000000000LL) finish(_wa, "y out of range", -1);

            int move = -1;
            
            for (int i = 1; i <= 3; i++) {
                if (i == last_idx) continue;
                
                p[i] += y;
                if (!check_collision()) {
                    move = i;
                    break; 
                }
                p[i] -= y; 
            }

            if (move != -1) {
                last_idx = move;
                cout << move << endl;
            } else {
                
                finish(_ok, "Interactor forced to lose (Human wins)", 0);
            }

        } else {
            
            long long y = get_win_move();
            cout << y << endl;

            int k;
            if (!(cin >> k)) finish(_wa, "Unexpected EOF reading pile index", -1);
            if (k < 1 || k > 3) finish(_wa, "Invalid pile index", -1);
            if (k == last_idx) finish(_wa, "Same pile chosen twice consecutively", -1);

            p[k] += y;
            last_idx = k;

            if (check_collision()) {
                finish(_wa, "Human made piles equal", -1);
            }
        }
    }

    
    if (human_is_first) {
        
        finish(_wa, "Limit reached without Human winning", -1);
    } else {
        
        finish(_ok, "Human survived 1000 turns", 0);
    }

    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 seedVal = 0;
    if (argc > 1) seedVal = atoll(argv[1]);

    vector<int> p;

    
    if (seedVal >= 1 && seedVal <= 5) {
        if (seedVal == 1) {
            
            p = {1, 2, 3};
        } else if (seedVal == 2) {
            
            p = {1000000000 - 2, 1000000000 - 1, 1000000000};
        } else if (seedVal == 3) {
            
            
            p = {1, 500000001, 1000000000};
        } else if (seedVal == 4) {
            
            p = {1, 2, 1000000000};
        } else {
            
            p = {1000000000, 500000000, 250000000};
        }
    } 
    else {
        
        set<int> s;
        while (s.size() < 3) {
            int x;
            if (mode == "adp") {
                
                
                
                if (rnd.next(10) < 7) {
                    x = rnd.next(900000000, 1000000000);
                } else {
                    x = rnd.next(1, 1000000000);
                }
            } else {
                
                x = rnd.next(1, 1000000000);
            }
            s.insert(x);
        }
        for (int x : s) p.push_back(x);
        
        
        shuffle(p.begin(), p.end());
    }

    
    println(p[0], p[1], p[2]);

    return 0;
}