#include using namespace std; using ll = long long; int main() { ios::sync_with_stdio(false); cin.tie(0); ll n, p, q; cin >> n >> p >> q; vector> a(n); for(int i = 0; i < n; i++){ auto &&[x, y, z, idx] = a[i]; idx = i; cin >> x >> y >> z; } sort(a.begin(), a.end(), [&](tuple lhs, tuple rhs){ return (get<1>(lhs) + get<2>(lhs)) * get<0>(rhs) < (get<1>(rhs) + get<2>(rhs)) * get<0>(lhs); }); vector> b(n); for(auto [x, y, z, idx] : a){ if(p > q){ ll d = min({x, y, p}); p -= d, x -= d; b[idx].first = d; d = min({x, z, q}); q -= d, x -= d; b[idx].second = d; }else{ ll d = min({x, z, q}); q -= d, x -= d; b[idx].second = d; d = min({x, y, p}); p -= d, x -= d; b[idx].first = d; } if(x != 0){ cout << "No\n"; return 0; } } cout << "Yes\n"; for(auto [x, y] : b) cout << x << ' ' << y << '\n'; }