/** * Amida, the City of Miracle (Problem A, Practice Contest for Japan Domestic, 2006-06-18) * by Kenji Inoue, 2007-01-05 **/ #include using namespace std; struct HL { int h, p, q; } hl[1001]; int main() { int n, m, a; while (cin >> n >> m >> a, (n || m || a)) { memset(hl, 0, sizeof(hl)); for (int i=0; i> hl[i].h >> hl[i].p >> hl[i].q; } int c = a; // current line for (int h=1000; h>0; h--) { for (int i=0; i