#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file 
#include <ext/pb_ds/tree_policy.hpp>
#include<math.h>
using namespace std;
using namespace __gnu_pbds;

typedef tree<long long int, null_type, less<long long int>, rb_tree_tag,
        tree_order_statistics_node_update>
        new_data_set;

int main() {
    long long int Q, K;
    cin >> Q >> K;
    new_data_set s;

    while (Q--) {
        int query;
        cin >> query;
        vector <long long int> v;
        long long int x, y;
        if (query == 1) {

            cin >> x >> y;
            v.push_back(x);
            v.push_back(y);
            int distance = x * x + y * y;
            s.insert(distance);
        } else {
            cout << *s.find_by_order(2) << endl;
        }
    }
    return 0;
}