func_code_string: #include <bits/stdc++.h>   using namespace std;   int n, m, k, d1[200005], d2[200005], ty, re1, re2, re3;   long long s, a[200005], b[200005], te;   vector<pair<long long, int> > v1, v2;   vector<long long> v3;   void bs(int lo, int up) {     int mid = (lo + up) / 2;     if (lo == up) {       v3.clear();       for (int i = 0; i < v2.size(); i++) v3.push_back(v2[i].first * b[mid]);       for (int i = 0; i < v1.size(); i++) {         if (v1[i].first * a[mid] > s) break;         int k1 = upper_bound(v3.begin(), v3.end(), s - v1[i].first * a[mid]) -                  v3.begin();         if (i + 1 + k1 >= k) {           re1 = i, re2 = k - i - 2, re3 = mid;           return;         }       }       if (v3.size() >= k && v3[k - 1] <= s) {         re1 = -1, re2 = k - 1;         re3 = mid;         return;       }     }     v3.clear();     for (int i = 0; i < v2.size(); i++) v3.push_back(v2[i].first * b[mid]);     for (int i = 0; i < v1.size(); i++) {       if (v1[i].first * a[mid] > s) break;       int k1 = upper_bound(v3.begin(), v3.end(), s - v1[i].first * a[mid]) -                v3.begin();       if (i + 1 + k1 >= k) {         re1 = i, re2 = k - i - 2, re3 = mid;         bs(lo, mid);         return;       }     }     if (v3.size() >= k && v3[k - 1] <= s) {       re1 = -1, re2 = k - 1;       re3 = mid;       bs(lo, mid);       return;     }     bs(mid + 1, up);   }   int main() {     cin >> n >> m >> k >> s;     a[0] = 1e9;     b[0] = 1e9;     for (int i = 1; i <= n; i++) {       cin >> a[i];       if (a[i] < a[i - 1])         d1[i] = i;       else         a[i] = a[i - 1], d1[i] = d1[i - 1];     }     v1.clear();     for (int i = 1; i <= n; i++) {       cin >> b[i];       if (b[i] < b[i - 1])         d2[i] = i;       else         b[i] = b[i - 1], d2[i] = d2[i - 1];     }     v2.clear();     for (int i = 1; i <= m; i++) {       cin >> ty;       if (ty == 1) {         cin >> te;         v1.push_back(pair<long long, int>(te, i));       } else {         cin >> te;         v2.push_back(pair<long long, int>(te, i));       }     }     sort(v1.begin(), v1.end());     sort(v2.begin(), v2.end());     for (int i = 1; i < v1.size(); i++) v1[i].first += v1[i - 1].first;     for (int i = 1; i < v2.size(); i++) v2[i].first += v2[i - 1].first;     re3 = 1e9;     v3.clear();     for (int i = 0; i < v2.size(); i++) v3.push_back(v2[i].first * b[n]);     for (int i = 0; i < v1.size(); i++) {       if (v1[i].first * a[n] > s) break;       int k1 =           upper_bound(v3.begin(), v3.end(), s - v1[i].first * a[n]) - v3.begin();       if (i + 1 + k1 >= k) {         re1 = i, re2 = k - i - 2, re3 = n;         break;       }     }     if (v3.size() >= k && v3[k - 1] <= s) {       re1 = -1, re2 = k - 1;       re3 = n;     }     if (re3 != 1e9) {       bs(1, n);       cout << re3 << endl;       for (int i = 0; i <= re1; i++)         cout << v1[i].second <<     << d1[re3] << endl;       for (int i = 0; i <= re2; i++)         cout << v2[i].second <<     << d2[re3] << endl;     } else       cout << -1 << endl;     return 0;   }   