#include<bits/stdc++.h>
using namespace std;

int main(){

  int a,b,c;
  cin>>a>>b>>c;
  
  if(a!=b && b!=c && c!=a){
  cout<<"0"<<endl;
  }
  else{
   //  int sum=a+b+c;
    if(a==b)
      	cout<<c<<endl;
    else if(b==c)
      	cout<<a<<endl;
    else
      	cout<<b<<endl;
  }
	

  return 0;
}
#include <bits/stdc++.h>
using namespace std;
// #include <atcoder/all>
// using namespace atcoder;

#define debug(args...) (Debugger()), args
class Debugger {
   public:
    Debugger(const std::string &_separator = " => ") : first(true), separator(_separator) {}

    template <typename ObjectType>
    Debugger &operator,(const ObjectType &v) {
        if (!first)
            cerr << separator;
        cerr << v;
        first = false;
        return *this;
    }
    ~Debugger() {
        cerr << endl;
    }

   private:
    bool first;
    string separator;
};
#define debug_var(x) debug(#x, x)

template <class T>
inline bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

template <class T>
inline bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}

#define rep(i, a, b) for (int i = a; i < b; i++)
#define all(container) container.begin(), container.end()
#define rall(container) container.rbegin(), container.rend()
#define forin(it, container) for (auto it = container.begin(); it != container.end(); it++)
#define rforin(it, container) for (auto it = container.rbegin(); it != container.rend(); it++)

typedef long l;
typedef long long ll;
typedef pair<int, int> ipi;
typedef pair<ll, ll> lpl;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<vector<vector<ll>>> vvvl;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<vector<vector<int>>> vvvi;

#define MOD 1'000'000'007

ll gcd(ll a, ll b) {
    return b == 0 ? a : gcd(b, a % b);
}

ll xpow(ll a, ll b, ll m) {
    ll res = 1;
    while (b > 0) {
        if (b & 1) {
            res = (res * a) % m;
        }
        a = (a * a) % m;
        b /= 2;
    }
    return res;
}

ll xmul(ll a, ll b, ll m) {
    ll res = 0;
    ll v = 1, k;
    while (b > 0) {
        if (b & 1) {
            k = (a * v) % m;
            res = (res + k) % m;
        }
        v = (v * 2) % m;
        b /= 2;
    }
    return res;
}

int main() {
    int n;
    ll ans = LONG_LONG_MAX;
    ll a, p, x;
    cin >> n;
    rep(i, 0, n) {
        cin >> a >> p >> x;
        if (x > a) {
            chmin(ans, p);
        }
    }
    cout << (ans == LONG_LONG_MAX ? -1 : ans);
    return 0;
}
