#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define reps(i, s, n) for(int i = (s); i < (n); i++)
#define rrep(i, n) for(int i = (n) - 1; i >= 0; i--)
#define rreps(i, s, n) for(int i = (n) - 1; i >= (s); i--)
#define INF ~(1 << 31)
#define INFL ~(1LL << 63)

int main(){
    int N;
    cin >> N;
    int minprice = INF;
    rep(i, N){
        int a, p, x;
        cin >> a >> p >> x;
        if(a < x){
            minprice = min(minprice, p);
        }
    }
    if(minprice == INF) minprice = -1;
    cout << minprice << endl;
}
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>

using namespace std;
#define ll long long

int main() {
	int a, b, w, min, max, goal, dif;
	bool stop = false;
	cin >> a >> b >> w;
	w *= 1000;
	if (w < a) cout << "UNSATISFIABLE";
	else if (a == b) {
		if (w % a == 0) cout << w / a << ' ' << w / a << '\n';
		else cout << "UNSATISFIABLE\n";
	}
	else {
		dif = b - a;
		goal = w;
		min = goal /b;
		goal %= b;
		if (goal > 0) {
			++min;
			goal = b - goal;
		}

		goal = goal - min * dif;
		if (goal > 0) {
			stop = true;
			cout << "UNSATISFIABLE\n";
		}

		if (!stop) {
			goal = w;
			max = goal / a;
			goal %= a;
			goal = goal - max * dif;
			if (goal > 0) {
				stop = true;
				cout << "UNSATISFIABLE\n";
			}
			if (!stop) cout << min << ' ' << max << '\n';
		}
	}

	return 0;
}