#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
using namespace std;

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef pair<int, int> P;
typedef set<P> SP;
typedef vector<P> VP;

int length(SP& s) {
  int mx = -100000, l = 0;
  for (SP::iterator it = s.begin(); it != s.end(); ++it) {
    if ((*it).first >= mx) {
      l += (*it).second - (*it).first;
      mx = (*it).second;
    }
    else {
      if ((*it).second > mx) {
	l += (*it).second - mx;
	mx = (*it).second;
      }
    }
  }
  return l;
}

int Buscar(SP& s, int xo) {
  int mx = -100000;
  for (SP::iterator it = s.begin(); it != s.end() and xo > 0; ++it) {
    if ((*it).first >= mx) {
      xo -= (*it).first - mx;
      mx = (*it).second;
    }
    else {
      if ((*it).second > mx) {
	mx = (*it).second;
      }
    }
  }
  return mx + xo;
}

int Buscar(int r, int xo, map<int, SP>& M) {
  for (map<int, SP>::iterator it = M.begin(); it != M.end(); ++it) {
    if (it->first == r) return Buscar(it->second, xo);
  }
  return -1;
}

int main() {
  int n, m, k; cin >> n >> m >> k;
  int xo = 0;
  map<int, SP> MV, MH;
  for (int i = 0; i < k; ++i) {
    int x1, y1, x2, y2; cin >> x1 >> y1 >> x2 >> y2;

    //Falta ver la interseccion
    if (x1 == x2) MV[x1].insert(P(min(y1, y2), max(y1, y2)));
    if (y1 == y2) MH[y1].insert(P(min(x1, x2), max(x1, x2)));
  }

  xo ^= n * abs((m - 1 - int(MH.size())) % 2);
//   cout << xo << endl;

  xo ^= m * abs((n - 1 - int(MV.size())) % 2);

//   cout << xo << endl;

  VP nimsh, nimsv;
  for (map<int, SP>::iterator it = MV.begin(); it != MV.end(); ++it) {
    nimsv.push_back(P(it->first, n - length(it->second)));
    xo ^= nimsv.back().second;
    cout << nimsv.back().second << endl;
  }

  for (map<int, SP>::iterator it = MH.begin(); it != MH.end(); ++it) {
    nimsh.push_back(P(it->first, m - length(it->second)));
    xo ^= nimsh.back().second;
    cout << nimsh.back().second << endl;
  }

  if (xo) {
    cout << "FIRST" << endl;
    bool found = false;
    int hcuts = nimsh.size();
    if (hcuts > 0) {
      int last = 0;
      for (int i = 0; i < hcuts; ++i) {
	if (nimsh[i].first > last + 1) {
	  cout << last + 1 << " 0 " << last + 1 << " " << xo << endl;
	  found = true;
	}
	else if (m - nimsh[i].second >= xo) {
	  cout << nimsh[i].first << " 0 " << nimsh[i].first << " " << Buscar(nimsh[i].first, xo, MH) << endl;
	  found = true;
	}
	last = nimsh[i].first;
      }
    }
    else if (n > 1) {
      cout << "1 0 1 " << xo << endl;
      found = true;
    }
    if (not found) {
      int vcuts = nimsv.size();
      int last = 0;
      if (vcuts > 0) {
	for (int i = 0; i < vcuts; ++i) {
	  if (nimsv[i].first > last + 1) {
	    cout << "0 " << last + 1 << " " << xo << " " << last + 1 << endl;
	    found = true;
	  }
	  else if (n - nimsv[i].second >= xo) {
	    cout << "0 " << nimsv[i].first << " " << Buscar(nimsv[i].first, xo, MV) << " " << nimsv[i].first << endl;
	    found = true;
	  }
	  last = nimsv[i].first;
	}
      }
      else if (m > 1) {
	cout << "0 1 " << xo << " 1" << endl;
	found = true;
      }
    }
  }
  else cout << "SECOND" << endl;
}


#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
using namespace std;

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef pair<int, int> P;
typedef set<P> SP;
typedef vector<P> VP;

int length(SP& s) {
  int mx = -100000, l = 0;
  for (SP::iterator it = s.begin(); it != s.end(); ++it) {
    if ((*it).first >= mx) {
      l += (*it).second - (*it).first;
      mx = (*it).second;
    }
    else {
      if ((*it).second > mx) {
	l += (*it).second - mx;
	mx = (*it).second;
      }
    }
  }
  return l;
}

int Buscar(SP& s, int xo) {
  int mx = -100000;
  for (SP::iterator it = s.begin(); it != s.end() and xo > 0; ++it) {
    if ((*it).first >= mx) {
      xo -= (*it).first - mx;
      mx = (*it).second;
    }
    else {
      if ((*it).second > mx) {
	mx = (*it).second;
      }
    }
  }
  return mx + xo;
}

int Buscar(int r, int xo, map<int, SP>& M) {
  for (map<int, SP>::iterator it = M.begin(); it != M.end(); ++it) {
    if (it->first == r) return Buscar(it->second, xo);
  }
  return -1;
}

int main() {
  int n, m, k; cin >> n >> m >> k;
  int xo = 0;
  map<int, SP> MV, MH;
  for (int i = 0; i < k; ++i) {
    int x1, y1, x2, y2; cin >> x1 >> y1 >> x2 >> y2;

    //Falta ver la interseccion
    if (x1 == x2) MV[x1].insert(P(min(y1, y2), max(y1, y2)));
    if (y1 == y2) MH[y1].insert(P(min(x1, x2), max(x1, x2)));
  }

  xo ^= n * abs((m - 1 - int(MH.size())) % 2);
//   cout << xo << endl;

  xo ^= m * abs((n - 1 - int(MV.size())) % 2);

//   cout << xo << endl;

  VP nimsh, nimsv;
  for (map<int, SP>::iterator it = MV.begin(); it != MV.end(); ++it) {
    nimsv.push_back(P(it->first, n - length(it->second)));
    xo ^= nimsv.back().second;
  }

  for (map<int, SP>::iterator it = MH.begin(); it != MH.end(); ++it) {
    nimsh.push_back(P(it->first, m - length(it->second)));
    xo ^= nimsh.back().second;
  }

  if (xo) {
    cout << "FIRST" << endl;
    bool found = false;
    int hcuts = nimsh.size();
    if (hcuts > 0) {
      int last = 0;
      for (int i = 0; i < hcuts; ++i) {
	if (nimsh[i].first > last + 1) {
	  cout << last + 1 << " 0 " << last + 1 << " " << xo << endl;
	  found = true;
	}
	else if (m - nimsh[i].second >= xo) {
	  cout << nimsh[i].first << " 0 " << nimsh[i].first << " " << Buscar(nimsh[i].first, xo, MH) << endl;
	  found = true;
	}
	last = nimsh[i].first;
      }
    }
    else if (n > 1) {
      cout << "1 0 1 " << xo << endl;
      found = true;
    }
    if (not found) {
      int vcuts = nimsv.size();
      int last = 0;
      if (vcuts > 0) {
	for (int i = 0; i < vcuts; ++i) {
	  if (nimsv[i].first > last + 1) {
	    cout << "0 " << last + 1 << " " << xo << " " << last + 1 << endl;
	    found = true;
	  }
	  else if (n - nimsv[i].second >= xo) {
	    cout << "0 " << nimsv[i].first << " " << Buscar(nimsv[i].first, xo, MV) << " " << nimsv[i].first << endl;
	    found = true;
	  }
	  last = nimsv[i].first;
	}
      }
      else if (m > 1) {
	cout << "0 1 " << xo << " 1" << endl;
	found = true;
      }
    }
  }
  else cout << "SECOND" << endl;
}


#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
using namespace std;

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef pair<int, int> P;
typedef set<P> SP;
typedef vector<P> VP;

int length(SP& s) {
  int mx = -100000, l = 0;
  for (SP::iterator it = s.begin(); it != s.end(); ++it) {
    if ((*it).first >= mx) {
      l += (*it).second - (*it).first;
      mx = (*it).second;
    }
    else {
      if ((*it).second > mx) {
	l += (*it).second - mx;
	mx = (*it).second;
      }
    }
  }
  return l;
}

int Buscar(SP& s, int xo) {
  int mx = -100000;
  for (SP::iterator it = s.begin(); it != s.end() and xo > 0; ++it) {
    if ((*it).first >= mx) {
      xo -= (*it).first - mx;
      mx = (*it).second;
    }
    else {
      if ((*it).second > mx) {
	mx = (*it).second;
      }
    }
  }
  return mx + xo;
}

int Buscar(int r, int xo, map<int, SP>& M) {
  for (map<int, SP>::iterator it = M.begin(); it != M.end(); ++it) {
    if (it->first == r) return Buscar(it->second, xo);
  }
  return -1;
}

int main() {
  int n, m, k; cin >> n >> m >> k;
  int xo = 0;
  map<int, SP> MV, MH;
  for (int i = 0; i < k; ++i) {
    int x1, y1, x2, y2; cin >> x1 >> y1 >> x2 >> y2;

    //Falta ver la interseccion
    if (x1 == x2) MV[x1].insert(P(min(y1, y2), max(y1, y2)));
    if (y1 == y2) MH[y1].insert(P(min(x1, x2), max(x1, x2)));
  }

  xo ^= n * abs((m - 1 - int(MH.size())) % 2);
//   cout << xo << endl;

  xo ^= m * abs((n - 1 - int(MV.size())) % 2);

//   cout << xo << endl;

  VP nimsh, nimsv;
  for (map<int, SP>::iterator it = MV.begin(); it != MV.end(); ++it) {
    nimsv.push_back(P(it->first, m - length(it->second)));
    xo ^= nimsv.back().second;
//     cout << nimsv.back().second << endl;
  }

  for (map<int, SP>::iterator it = MH.begin(); it != MH.end(); ++it) {
    nimsh.push_back(P(it->first, n - length(it->second)));
    xo ^= nimsh.back().second;
//     cout << nimsh.back().second << endl;
  }

//   cout << xo << endl;
  if (xo) {
    cout << "FIRST" << endl;
    bool found = false;
    int hcuts = nimsh.size();
    if (hcuts > 0) {
      int last = 0;
      for (int i = 0; i < hcuts; ++i) {
	if (xo <= n and nimsh[i].first > last + 1) {
	  cout << last + 1 << " 0 " << last + 1 << " " << xo << endl;
	  found = true;
	}
	else if (n - nimsh[i].second >= (xo ^ nimsh[i].second)) {
	  cout << nimsh[i].first << " 0 " << nimsh[i].first << " " << Buscar(nimsh[i].first, xo ^ nimsh[i].second, MH) << endl;
	  found = true;
	}
	last = nimsh[i].first;
      }
    }
    else if (n > 1) {
      cout << "1 0 1 " << xo << endl;
      found = true;
    }
    if (not found) {
      int vcuts = nimsv.size();
      int last = 0;
      if (vcuts > 0) {
	for (int i = 0; i < vcuts; ++i) {
	  if (xo <= m and nimsv[i].first > last + 1) {
	    cout << "0 " << last + 1 << " " << xo << " " << last + 1 << endl;
	    found = true;
	  }
	  else if (m - nimsv[i].second >= (xo ^ nimsv[i].second)) {
	    cout << "0 " << nimsv[i].first << " " << Buscar(nimsv[i].first, xo ^ nimsv[i].second, MV) << " " << nimsv[i].first << endl;
	    found = true;
	  }
	  last = nimsv[i].first;
	}
      }
      else if (m > 1) {
	cout << "0 1 " << xo << " 1" << endl;
	found = true;
      }
    }
  }
  else cout << "SECOND" << endl;
}


#include <iostream>
#include <vector>
#include <map>
#include <set>
using namespace std;

typedef pair<int, int> PII;
typedef set<PII> SPII;
typedef map<int, SPII> MSPII;
typedef vector<PII> VPII;

int length(SPII& s) {
  int last = 0, len = 0;
  for (SPII::iterator it = s.begin(); it != s.end(); ++it) {
    if (last <= it->first) {
      len += it->second - it->first;
      last = it->second;
    }
    else if (it->second >= last) {
      len += it->second - last;
      last = it->second;
    }
  }
  return len;
}

int Buscar(SPII& s, int obj) {
  int last = 0, len = 0;
  for (SPII::iterator it = s.begin(); it != s.end(); ++it) {
    if (it->first >= last) {
      len += it->first - last;
      last = it->second;
      if (len >= obj) {
	return last - (len - obj);
      }
    }
    else last = max(last, it->second);
  }
  return last - (len - obj);
}

int main() {
  int w, h, k; cin >> w >> h >> k;
  MSPII hcuts, vcuts;
  for (int i = 0; i < k; ++i) {
    int x1, y1, x2, y2; cin >> x1 >> y1 >> x2 >> y2;
    if (x1 == x2) vcuts[x1].insert(PII(min(y1, y2), max(y1, y2)));
    else hcuts[y1].insert(PII(min(x1, x2), max(x1, x2)));
  }

  int nim = 0;
  nim ^= h * ((w - 1 - vcuts.size()) % 2);
  nim ^= w * ((h - 1 - hcuts.size()) % 2);

  VPII hc, vc;
  for (MSPII::iterator it = hcuts.begin(); it != hcuts.end(); ++it) {
    hc.push_back(PII(it->first, w - length(it->second)));
    nim ^= hc.back().second;
  }
  for (MSPII::iterator it = vcuts.begin(); it != vcuts.end(); ++it) {
    vc.push_back(PII(it->first, h - length(it->second)));
    nim ^= vc.back().second;
  }

//   cout << nim << endl;

  if (nim) {
    cout << "FIRST" << endl;
    bool found = false;
    //Cortes verticales
    int last = 0, nvc = vc.size();
    for (int j = 0; j < nvc and not found; ++j) {
      int col = vc[j].first;
      if (col > last + 1) {
	if ((nim ^ h) <= h) {
	  cout << last + 1 << " 0 " << last + 1 << " " << h - (nim ^ h) << endl;
	  found = true;
	}
      }
      if (not found) {
	int libre = vc[j].second;
	if ((nim ^ libre) <= libre) {
	  cout << col << " " << Buscar(vcuts[col], nim ^ libre) << " " << col << " " << h << endl;
	  found = true;
	}
      }
      last = col;
    }
    if (not found and w > last + 1) {
      if ((nim ^ h) <= h) {
	cout << last + 1 << " 0 " << last + 1 << " " << h - (nim ^ h) << endl;
	found = true;
      }
    }

    last = 0;
    int nhc = hc.size();
    for (int j = 0; j < nhc and not found; ++j) {
      int row = hc[j].first;
      if (row > last + 1) {
	if ((nim ^ w) <= w) {
	  cout << "0 " << last + 1 << " " << w - (nim ^ w) << " " << last + 1 << endl;
	  found = true;
	}
      }
      if (not found) {
	int libre = hc[j].second;
	if ((nim ^ libre) <= libre) {
	  cout << Buscar(hcuts[row], nim ^ libre) << " " << row << " " << w << " " << row << endl;
	  found = true;
	}
      }
      last = row;
    }
    if (not found and h > last + 1) {
      if ((nim ^ w) <= w) {
	cout << "0 " << last + 1 << " " << w - (nim ^ w) << " " << last + 1 << endl;
	found = true;
      }
    }
  }
  else cout << "SECOND" << endl;
}


#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
using namespace std;

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef pair<int, int> P;
typedef set<P> SP;
typedef vector<P> VP;

int length(SP& s) {
  int mx = -100000, l = 0;
  for (SP::iterator it = s.begin(); it != s.end(); ++it) {
    if ((*it).first >= mx) {
      l += (*it).second - (*it).first;
      mx = (*it).second;
    }
    else {
      if ((*it).second > mx) {
	l += (*it).second - mx;
	mx = (*it).second;
      }
    }
  }
  return l;
}

int Buscar(SP& s, int xo) {
  int mx = -100000;
  for (SP::iterator it = s.begin(); it != s.end() and xo > 0; ++it) {
    if ((*it).first >= mx) {
      xo -= (*it).first - mx;
      mx = (*it).second;
    }
    else {
      if ((*it).second > mx) {
	mx = (*it).second;
      }
    }
  }
  return mx + xo;
}

int Buscar(int r, int xo, map<int, SP>& M) {
  for (map<int, SP>::iterator it = M.begin(); it != M.end(); ++it) {
    if (it->first == r) return Buscar(it->second, xo);
  }
  return -1;
}

int main() {
  int w, h, k; cin >> w >> h >> k;
  int xo = 0;
  map<int, SP> MV, MH;
  for (int i = 0; i < k; ++i) {
    int x1, y1, x2, y2; cin >> x1 >> y1 >> x2 >> y2;

    //Falta ver la interseccion
    if (x1 == x2) MV[x1].insert(P(min(y1, y2), max(y1, y2)));
    if (y1 == y2) MH[y1].insert(P(min(x1, x2), max(x1, x2)));
  }

  xo ^= w * abs((h - 1 - int(MH.size())) % 2);
//   cout << xo << endl;

  xo ^= h * abs((w - 1 - int(MV.size())) % 2);

//   cout << xo << endl;

  VP nimsh, nimsv;
  for (map<int, SP>::iterator it = MV.begin(); it != MV.end(); ++it) {
    nimsv.push_back(P(it->first, h - length(it->second)));
    xo ^= nimsv.back().second;
//     cout << nimsv.back().second << endl;
  }

  for (map<int, SP>::iterator it = MH.begin(); it != MH.end(); ++it) {
    nimsh.push_back(P(it->first, w - length(it->second)));
    xo ^= nimsh.back().second;
//     cout << nimsh.back().second << endl;
  }

//   cout << xo << endl;
  if (xo) {
    cout << "FIRST" << endl;
    bool found = false;
    int hcuts = nimsh.size();
    if (hcuts > 0) {
      int last = 0;
      for (int i = 0; i < hcuts; ++i) {
	if ((xo ^ w) <= w and nimsh[i].first > last + 1) {
	  cout << "0 " << last + 1 << " " << w - (xo ^ w)<< " " << last + 1 << endl;
	  found = true;
	}
	else if (w - nimsh[i].second >= (xo ^ (w - nimsh[i].second))) {
	  cout << "0 " << nimsh[i].first << " " << Buscar(w - nimsh[i].first, (xo ^ (w - nimsh[i].second)), MH)<< " " << nimsh[i].first << endl;
	  found = true;
	}
	last = nimsh[i].first;
      }
    }
    else if (h > 1 and (xo ^ w) <= w) {
      cout << "0 1 " << w - (xo ^ w) << " 1" << endl;
      found = true;
    }
    if (not found) {
      int vcuts = nimsv.size();
      int last = 0;
      if (vcuts > 0) {
	for (int i = 0; i < vcuts; ++i) {
	  if ((xo ^ h) <= h and nimsv[i].first > last + 1) {
	    cout << last + 1 << " 0 " << last + 1 << " " << h - (xo ^ h) << endl;
	    found = true;
	  }
	  else if (h - nimsv[i].second >= (xo ^ (h - nimsv[i].second))) {
	    cout << nimsv[i].first << " 0 " << nimsv[i].first << " " << Buscar(nimsv[i].first, h - (xo ^ (h - nimsv[i].second)), MV) << endl;
	    found = true;
	  }
	  last = nimsv[i].first;
	}
      }
      else if (w > 1 and (xo ^ h) <= h) {
// 	    cout << "caca" << endl;
	cout << "1 0 1 " << h - (xo ^ h) << endl;
	found = true;
      }
    }
  }
  else cout << "SECOND" << endl;
}


#include <iostream>
#include <vector>
#include <map>
#include <set>
using namespace std;

typedef pair<int, int> PII;
typedef set<PII> SPII;
typedef map<int, SPII> MSPII;
typedef vector<PII> VPII;

int length(SPII& s) {
  int last = 0, len = 0;
  for (SPII::iterator it = s.begin(); it != s.end(); ++it) {
    if (last <= it->first) {
      len += it->second - it->first;
      last = it->second;
    }
    else if (it->second >= last) {
      len += it->second - last;
      last = it->second;
    }
  }
  return len;
}

int Buscar(SPII& s, int obj) {
  int last = 0, len = 0;
  for (SPII::iterator it = s.begin(); it != s.end(); ++it) {
    if (it->first >= last) {
      len += it->first - last;
      last = it->second;
      if (len >= obj) {
	return last - (len - obj);
      }
    }
    else last = max(last, it->second);
  }
  return len;
}

int main() {
  int w, h, k; cin >> w >> h >> k;
  MSPII hcuts, vcuts;
  for (int i = 0; i < k; ++i) {
    int x1, y1, x2, y2; cin >> x1 >> y1 >> x2 >> y2;
    if (x1 == x2) vcuts[x1].insert(PII(min(y1, y2), max(y1, y2)));
    else hcuts[y1].insert(PII(min(x1, x2), max(x1, x2)));
  }

  int nim = 0;
  nim ^= h * ((w - 1 - vcuts.size()) % 2);
  nim ^= w * ((h - 1 - hcuts.size()) % 2);

  VPII hc, vc;
  for (MSPII::iterator it = hcuts.begin(); it != hcuts.end(); ++it) {
    hc.push_back(PII(it->first, w - length(it->second)));
    nim ^= hc.back().second;
  }
  for (MSPII::iterator it = vcuts.begin(); it != vcuts.end(); ++it) {
    vc.push_back(PII(it->first, h - length(it->second)));
    nim ^= vc.back().second;
  }

//   cout << nim << endl;

  if (nim) {
    cout << "FIRST" << endl;
    bool found = false;
    //Cortes verticales
    int last = 0, nvc = vc.size();
    for (int j = 0; j < nvc and not found; ++j) {
      int col = vc[j].first;
      if (col > last + 1) {
	if ((nim ^ h) <= h) {
	  cout << last + 1 << " 0 " << last + 1 << " " << h - (nim ^ h) << endl;
	  found = true;
	}
      }
      if (not found) {
	int libre = vc[j].second;
	if ((nim ^ libre) <= libre) {
	  cout << col << " " << Buscar(vcuts[col], nim ^ libre) << " " << col << " " << h << endl;
	  found = true;
	}
      }
      last = col;
    }
    if (not found and w > last + 1) {
      if ((nim ^ h) <= h) {
	cout << last + 1 << " 0 " << last + 1 << " " << h - (nim ^ h) << endl;
	found = true;
      }
    }

    last = 0;
    int nhc = hc.size();
    for (int j = 0; j < nhc and not found; ++j) {
      int row = hc[j].first;
      if (row > last + 1) {
	if ((nim ^ w) <= w) {
	  cout << "0 " << last + 1 << " " << w - (nim ^ w) << " " << last + 1 << endl;
	  found = true;
	}
      }
      if (not found) {
	int libre = hc[j].second;
	if ((nim ^ libre) <= libre) {
	  cout << Buscar(hcuts[row], nim ^ libre) << " " << row << " " << w << " " << row << endl;
	  found = true;
	}
      }
      last = row;
    }
    if (not found and h > last + 1) {
      if ((nim ^ w) <= w) {
	cout << "0 " << last + 1 << " " << w - (nim ^ w) << " " << last + 1 << endl;
	found = true;
      }
    }
  }
  else cout << "SECOND" << endl;
}


#include <iostream>
#include <vector>
#include <map>
#include <set>
using namespace std;

typedef pair<int, int> PII;
typedef set<PII> SPII;
typedef map<int, SPII> MSPII;
typedef vector<PII> VPII;

int length(SPII& s) {
  int last = 0, len = 0;
  for (SPII::iterator it = s.begin(); it != s.end(); ++it) {
    if (last <= it->first) {
      len += it->second - it->first;
      last = it->second;
    }
    else if (it->second >= last) {
      len += it->second - last;
      last = it->second;
    }
  }
  return len;
}

int Buscar(SPII& s, int obj) {
  int last = 0, len = 0;
  for (SPII::iterator it = s.begin(); it != s.end(); ++it) {
    if (it->first >= last) {
      len = it->first - last;
      last = it->second;
      if (len >= obj) {
	return last - (len - obj);
      }
    }
    else last = max(last, it->second);
  }
  return len;
}

int main() {
  int w, h, k; cin >> w >> h >> k;
  MSPII hcuts, vcuts;
  for (int i = 0; i < k; ++i) {
    int x1, y1, x2, y2; cin >> x1 >> y1 >> x2 >> y2;
    if (x1 == x2) vcuts[x1].insert(PII(min(y1, y2), max(y1, y2)));
    else hcuts[y1].insert(PII(min(x1, x2), max(x1, x2)));
  }

  int nim = 0;
  nim ^= h * ((w - 1 - vcuts.size()) % 2);
  nim ^= w * ((h - 1 - hcuts.size()) % 2);

  VPII hc, vc;
  for (MSPII::iterator it = hcuts.begin(); it != hcuts.end(); ++it) {
    hc.push_back(PII(it->first, w - length(it->second)));
    nim ^= hc.back().second;
  }
  for (MSPII::iterator it = vcuts.begin(); it != vcuts.end(); ++it) {
    vc.push_back(PII(it->first, h - length(it->second)));
    nim ^= vc.back().second;
  }

//   cout << nim << endl;

  if (nim) {
    cout << "FIRST" << endl;
    bool found = false;
    //Cortes verticales
    int last = 0, nvc = vc.size();
    for (int j = 0; j < nvc and not found; ++j) {
      int col = vc[j].first;
      if (col > last + 1) {
	if ((nim ^ h) <= h) {
	  cout << last + 1 << " 0 " << last + 1 << " " << h - (nim ^ h) << endl;
	  found = true;
	}
      }
      if (not found) {
	int libre = vc[j].second;
	if ((nim ^ libre) <= libre) {
	  cout << col << " " << Buscar(vcuts[col], nim ^ libre) << " " << col << " " << h << endl;
	  found = true;
	}
      }
      last = col;
    }
    if (not found and w > last + 1) {
      if ((nim ^ h) <= h) {
	cout << last + 1 << " 0 " << last + 1 << " " << h - (nim ^ h) << endl;
	found = true;
      }
    }

    last = 0;
    int nhc = hc.size();
    for (int j = 0; j < nhc and not found; ++j) {
      int row = hc[j].first;
      if (row > last + 1) {
	if ((nim ^ w) <= w) {
	  cout << "0 " << last + 1 << " " << w - (nim ^ w) << " " << last + 1 << endl;
	  found = true;
	}
      }
      if (not found) {
	int libre = hc[j].second;
	if ((nim ^ libre) <= libre) {
	  cout << Buscar(hcuts[row], nim ^ libre) << " " << row << " " << w << " " << row << endl;
	  found = true;
	}
      }
      last = row;
    }
    if (not found and h > last + 1) {
      if ((nim ^ w) <= w) {
	cout << "0 " << last + 1 << " " << w - (nim ^ w) << " " << last + 1 << endl;
	found = true;
      }
    }
  }
  else cout << "SECOND" << endl;
}


#include <iostream>
#include <cstdio>
#include <memory.h>
#include <vector>
#include <set>
#include <string>
#include <cmath>
#include <stdio.h>
#include <algorithm>
#include <queue>
#include <stack>

#define file_name ""

typedef long long ll;
const int N = 1e5+5;

#define mp make_pair
using namespace std;

int cmp(pair <pair <int, int >, int > a, pair <pair < int, int >, int > b)
{
    return (a.second<b.second || (a.second==b.second && a.first<b.first));
}

int ans;
ll func(vector <pair <pair <int, int >, int> > &v, int n, int m)
{
    ll d=0,c=0,res=0;
    int len = v.size();
    ll x,y;
    for(int i=0;i<len;++i)
    {
        if (!i || v[i].second != v[i-1].second) {
            c++;
            if (i) res^=(n-d);
        //   cout<<"!!"<<d<<" "<<res<<" "<<v[i].first.first<<" "<<v[i].first.second<<" "<<v[i].second<<endl;
            d=0; d+=v[i].first.second-v[i].first.first;
            y = v[i].first.second;
            x = v[i].first.first;
        //    cout<<"!!"<<d<<" "<<i<<endl;
        }
        else
        {
            x = max((ll)v[i].first.first,max(x,y));
            y = v[i].first.second;
     //       cout<<x<<"  !!!     "<<y<<endl;
            if (y>x)d+=y-x;
        }
    }
    if (!v.empty())res^=(n-d);
   // cout<<res<<endl;
    if (c!=m-1 && (m-c-1)%2) res^=n;
  //  cout<<res<<" "<<c<<" "<<m<<" "<<(c!=m-1) <<" "<< (m-c-1)%2<<endl;
    return res;
}
int main()
{
    //    freopen(file_name".in","r",stdin);
    //    freopen(file_name".out","w",stdout);
    ll n,m,k;
    cin>>m>>n>>k;
    vector <pair <pair <int, int >, int> > v;
    vector <pair <pair <int, int >, int> > g;
    int x,y,z,d;
    for(int i=0;i<k;++i)
    {
        cin>>x>>y>>z>>d;
        if (x==z) v.push_back(mp(mp(min(y,d),max(y,d)),x));
        else g.push_back(mp(mp(min(x,z),max(x,z)),y));
    }

    sort(v.begin(),v.end(),cmp);
    sort(g.begin(),g.end(),cmp);

    ll a = func(v,n,m)^func(g,m,n);

   // cout<<"====\n";
   //cout<<a<<"!"<<func(g,m,n)<<endl;
    //cout<<b<<endl;
    if (a==0) cout<<"SECOND";
    else
    {
        cout<<"FIRST\n";
        int j=0;
        int l,r,j0;
        ll t =0;
        if (1)
        {
            for(int i=1;i<=n-1;++i)
            {
                j0=j;
                if ((j>=g.size() || i!=g[j].second)) {t = m;}
                else
                {
              //      cout<<i<<" "<<g[j].first.first<<" "<< g[j].first.second<<" "<<g[j].second<< endl;
                    l = g[j].first.first;
                    t=0;
                    r = g[j].first.second;
                    t+=r-l;
                    j++;
                    while(j<g.size() && g[j].second==i)
                    {
                        l = max(g[j].first.first,max(l,r));
                        r = g[j].first.second;
                        if (r>l) t+=r-l;
                        j++;
                    }

                    t = m-t;
                }
              // cout<<a<<" "<<t<<" "<<g.size()<<" "<<j<<endl;

                if ((a^t)<t)
                {
                    ll h=a^t;
                  //  cout<<a<<' '<<h<<" "<<t<<endl;
                    j=j0;
                    l=r=0;
                    t=0;

                    if (j<g.size() && i==g[j].second)
                    {
                        l = g[j].first.first;
                        t = (l?l:0);
                        l = r = g[j].first.second;

                        if (t>=h) {cout<<h<<" "<<i<<" "<<m<<" "<<i; return 0;}
                        j++;
                    }
                 //   cout<<h<<' '<<t<<endl;
                    while(j<g.size() && g[j].second==i)
                    {

                        if (l<g[j].first.first && g[j].first.first>r && g[j].first.first-r+t>=h) {cout<<r+h-t<<" "<<i<<" "<<m<<" "<<i; return 0;}
                        if (l<g[j].first.first && g[j].first.first>r) t+=g[j].first.first-r;
                        r = g[j].first.second;
                        l = max(l,r);
                        j++;
                    }
                  //  cout<<h<<" "<<t<<" "<<r<<endl;
                    cout<<r+h-t<<" "<<i<<" "<<m<<" "<<i;

                    return 0;
                }
            }
        }
        if (1)
        {
            t=j=0;
            for(int i=1;i<=m-1;++i)
            {
                j0=j;
                if ((j>=v.size() || i!=v[j].second)) {t = n;}
                else
                {
                    l = v[j].first.first;
                    t=0;
                    r = v[j].first.second;
                    t+=r-l;
                    j++;
                    while(j<v.size() && v[j].second==i)
                    {
                        l = max(v[j].first.first,max(l,r));
                        r = v[j].first.second;
                        if (r>l) t+=r-l;
                        j++;
                    }

                    t = n-t;
                }
                if ((a^t)<t)
                {

                    ll h=a^t;
                    if (h<0) continue;
                    j=j0;
                    t=0;
                    l=r=0;
                    if (j<v.size() && v[j].second==i)
                    {
                        l = v[j].first.first;

                        r = v[j].first.second;

                         t = (l?l:0);
                         l=r;
                        if (t>=h) {cout<<i<<" "<<h<<" "<<i<<" "<<n; return 0;}
                        j++;
                    }
                    while(j<v.size() && v[j].second==i)
                    {
                        if (l<v[j].first.first && v[j].first.first>r && v[j].first.first-r+t>=h) {cout<<i<<" "<<r+h-t<<" "<<i<<" "<<n; return 0;}
                        if (l<v[j].first.first && v[j].first.first>r) t+=v[j].first.first-r;

                        r = v[j].first.second;
                        l =max(l,r);
                        j++;
                    }
              //      cout<<h<< " "<<t<<" "<<r<<" "<<endl;
                    cout<<i<<" "<<r+h-t<<" "<<i<<" "<<n;

                    return 0;
                }

            }
        }
    }
    return 0;
}


#include <iostream>
#include <cstdio>
#include <memory.h>
#include <vector>
#include <set>
#include <string>
#include <cmath>
#include <stdio.h>
#include <algorithm>
#include <queue>
#include <stack>

#define file_name ""

typedef long long ll;
const int N = 1e5+5;

#define mp make_pair
using namespace std;

int cmp(pair <pair <int, int >, int > a, pair <pair < int, int >, int > b)
{
    return (a.second<b.second || (a.second==b.second && a.first<b.first));
}

int ans;
ll func(vector <pair <pair <int, int >, int> > &v, int n, int m)
{
    ll d=0,c=0,res=0;
    int len = v.size();
    ll x,y;
    for(int i=0;i<len;++i)
    {
        if (!i || v[i].second != v[i-1].second) {
            c++;
            if (i) res^=(n-d);
         //  cout<<"!!"<<d<<" "<<res<<" "<<v[i].first.first<<" "<<v[i].first.second<<" "<<v[i].second<<endl;
            d=0; d+=v[i].first.second-v[i].first.first;
           // cout<<"!!"<<d<<endl;
        }
        else
        {
            x = max(v[i].first.first,v[i-1].first.second);
            y = v[i].first.second;
            if (y>v[i-1].first.second)d+=y-x;
        }
    }
    if (!v.empty())res^=(n-d);
    //cout<<res<<endl;
    if (c!=m-1 && (m-c-1)%2) res^=n;
   // cout<<res<<" "<<c<<" "<<m<<" "<<(c!=m-1) <<" "<< (m-c-1)%2<<endl;
    return res;
}
int main()
{
    //    freopen(file_name".in","r",stdin);
    //    freopen(file_name".out","w",stdout);
    ll n,m,k;
    cin>>m>>n>>k;
    vector <pair <pair <int, int >, int> > v;
    vector <pair <pair <int, int >, int> > g;
    int x,y,z,d;
    for(int i=0;i<k;++i)
    {
        cin>>x>>y>>z>>d;
        if (x==z) v.push_back(mp(mp(min(y,d),max(y,d)),x));
        else g.push_back(mp(mp(min(x,z),max(x,z)),y));
    }

    sort(v.begin(),v.end(),cmp);
    sort(g.begin(),g.end(),cmp);

    ll a = func(v,n,m)^func(g,m,n);
  //  cout<<a<<"!"<<func(v,n,m)<<endl;
    //cout<<b<<endl;
    if (a==0) cout<<"SECOND";
    else
    {
        cout<<"FIRST\n";
        int j=0;
        int l,r,j0;
        ll t =0;
        if (1)
        {
            for(int i=1;i<=n-1;++i)
            {
                j0=j;
                if ((j>=g.size() || i!=g[j].second)) {t = m;}
                else
                {
              //      cout<<i<<" "<<g[j].first.first<<" "<< g[j].first.second<<" "<<g[j].second<< endl;
                    l = g[j].first.first;
                    t=0;
                    r = g[j].first.second;
                    t+=r-l;
                    j++;
                    while(j<g.size() && g[j].second==i)
                    {
                        l = max(g[j].first.first,r);
                        r = g[j].first.second;
                        t+=r-l;
                        j++;
                    }

                    t = m-t;
                }
              // cout<<a<<" "<<t<<" "<<g.size()<<" "<<j<<endl;

                if ((a^t)<t)
                {
                    ll h=a^t;
                    h = m-h;
                    //cout<<a<<' '<<h<<" "<<t<<endl;
                    j=j0;
                    l=r=0;
                    t=0;

                    if (j<g.size() && i==g[j].second)
                    {
                        l = g[j].first.first;
                        t=0;
                        r = g[j].first.second;
                        t=r;
                        j++;
                    }
                 //   cout<<h<<' '<<t<<endl;
                    while(j<g.size() && g[j].second==i)
                    {
                        if(g[j].first.first>r)
                        {
                            if (g[j].first.second-r+t>=h) {cout<<0<<" "<<i<<" "<<r+h-t<<" "<<i; return 0;}
                            else t+=g[j].first.second-r;
                        }
                        r = g[j].first.second;
                        j++;
                    }
                //    cout<<h<<" "<<t<<" "<<r<<endl;
                    cout<<0<<" "<<i<<" "<<r+h-t<<" "<<i;

                    return 0;
                }
            }
        }
        if (1)
        {
            t=j=0;
            for(int i=1;i<=m-1;++i)
            {
                j0=j;
                if ((j>=v.size() || i!=v[j].second)) {t = n;}
                else
                {
                    l = v[j].first.first;
                    t=0;
                    //if(l) t = l;

                    r = v[j].first.second;
                    t+=r-l;
                    j++;
                    while(j<v.size() && v[j].second==i)
                    {
                        l = max(v[j].first.first,r);
                        r = v[j].first.second;
                        t+=r-l;
                        j++;
                    }

                    t = n-t;
                }
                if ((a^t)<t)
                {

                    ll h=a^t;
                    h = n-h;
                    j=j0;
                    t=0;
                    l=r=0;
                    if (j<v.size() && v[j].second==i)
                    {
                        l = v[j].first.first;

                        r = v[j].first.second;
                        t=r;
                        j++;
                    }
                    while(j<v.size() && v[j].second==i)
                    {

                        if(v[j].first.first>r)
                        {
                            if (v[j].first.second-r+t>=h) {cout<<i<<" "<<0<<" "<<i<<" "<<r+h-t; return 0;}
                            else t+=v[j].first.second-r;
                        }
                        r = v[j].first.second;
                        j++;
                    }
              //      cout<<h<< " "<<t<<" "<<r<<" "<<endl;
                    cout<<i<<" "<<0<<" "<<i<<" "<<r+h-t;

                    return 0;
                }

            }
        }
    }
    return 0;
}


#include <iostream>
#include <cstdio>
#include <memory.h>
#include <vector>
#include <set>
#include <string>
#include <cmath>
#include <stdio.h>
#include <algorithm>
#include <queue>
#include <stack>

#define file_name ""

typedef long long ll;
const int N = 1e5+5;

#define mp make_pair
using namespace std;

int cmp(pair <pair <int, int >, int > a, pair <pair < int, int >, int > b)
{
    return (a.second<b.second || (a.second==b.second && a.first<b.first));
}

int ans;
ll func(vector <pair <pair <int, int >, int> > &v, int n, int m)
{
    ll d=0,c=0,res=0;
    int len = v.size();
    ll x,y;
    for(int i=0;i<len;++i)
    {
        if (!i || v[i].second != v[i-1].second) {
            c++;
            if (i) res^=(n-d);
       //    cout<<"!!"<<d<<" "<<res<<" "<<v[i].first.first<<" "<<v[i].first.second<<" "<<v[i].second<<endl;
            d=0; d+=v[i].first.second-v[i].first.first;
            y = v[i].first.second;
            x = v[i].first.first;
        //    cout<<"!!"<<d<<" "<<i<<endl;
        }
        else
        {
            x = max((ll)v[i].first.first,max(x,y));
            y = v[i].first.second;
     //       cout<<x<<"  !!!     "<<y<<endl;
            if (y>x)d+=y-x;
        }
    }
    if (!v.empty())res^=(n-d);
   // cout<<res<<endl;
    if (c!=m-1 && (m-c-1)%2) res^=n;
   // cout<<res<<" "<<c<<" "<<m<<" "<<(c!=m-1) <<" "<< (m-c-1)%2<<endl;
    return res;
}
int main()
{
    //    freopen(file_name".in","r",stdin);
    //    freopen(file_name".out","w",stdout);
    ll n,m,k;
    cin>>m>>n>>k;
    vector <pair <pair <int, int >, int> > v;
    vector <pair <pair <int, int >, int> > g;
    int x,y,z,d;
    for(int i=0;i<k;++i)
    {
        cin>>x>>y>>z>>d;
        if (x==z) v.push_back(mp(mp(min(y,d),max(y,d)),x));
        else g.push_back(mp(mp(min(x,z),max(x,z)),y));
    }

    sort(v.begin(),v.end(),cmp);
    sort(g.begin(),g.end(),cmp);

    ll a = func(v,n,m)^func(g,m,n);

   // cout<<"====\n";
 //  cout<<a<<"!"<<func(v,n,m)<<endl;
    //cout<<b<<endl;
    if (a==0) cout<<"SECOND";
    else
    {
        cout<<"FIRST\n";
        int j=0;
        int l,r,j0;
        ll t =0;
        if (1)
        {
            for(int i=1;i<=n-1;++i)
            {
                j0=j;
                if ((j>=g.size() || i!=g[j].second)) {t = m;}
                else
                {
              //      cout<<i<<" "<<g[j].first.first<<" "<< g[j].first.second<<" "<<g[j].second<< endl;
                    l = g[j].first.first;
                    t=0;
                    r = g[j].first.second;
                    t+=r-l;
                    j++;
                    while(j<g.size() && g[j].second==i)
                    {
                        l = max(g[j].first.first,r);
                        r = g[j].first.second;
                        t+=r-l;
                        j++;
                    }

                    t = m-t;
                }
              // cout<<a<<" "<<t<<" "<<g.size()<<" "<<j<<endl;

                if ((a^t)<t)
                {
                    ll h=a^t;
                  //  cout<<a<<' '<<h<<" "<<t<<endl;
                    j=j0;
                    l=r=0;
                    t=0;

                    if (j<g.size() && i==g[j].second)
                    {
                        l = g[j].first.first;
                        t = (l?l:0);
                        r = g[j].first.second;

                        if (t>=h) {t=h,r=0;}
                        j++;
                    }
                 //   cout<<h<<' '<<t<<endl;
                    while(j<g.size() && g[j].second==i)
                    {
                        if (g[j].first.first>r && g[j].first.first-r+t>=h) {cout<<r+h-t<<" "<<i<<" "<<m<<" "<<i; return 0;}
                        if (g[j].first.first>r) t+=g[j].first.first-r;
                        r = g[j].first.second;
                        j++;
                    }
                  //  cout<<h<<" "<<t<<" "<<r<<endl;
                    cout<<r+h-t<<" "<<i<<" "<<m<<" "<<i;

                    return 0;
                }
            }
        }
        if (1)
        {
            t=j=0;
            for(int i=1;i<=m-1;++i)
            {
                j0=j;
                if ((j>=v.size() || i!=v[j].second)) {t = n;}
                else
                {
                    l = v[j].first.first;
                    t=0;
                    r = v[j].first.second;
                    t+=r-l;
                    j++;
                    while(j<v.size() && v[j].second==i)
                    {
                        l = max(v[j].first.first,r);
                        r = v[j].first.second;
                        t+=r-l;
                        j++;
                    }

                    t = n-t;
                }
                if ((a^t)<t)
                {

                    ll h=a^t;
                    if (h<0) continue;
                    j=j0;
                    t=0;
                    l=r=0;
                    if (j<v.size() && v[j].second==i)
                    {
                        l = v[j].first.first;

                        r = v[j].first.second;

                         t = (l?l:0);
                        if (t>=h) {t=h,r=0;}
                        j++;
                    }
                    while(j<v.size() && v[j].second==i)
                    {
                        if (v[j].first.first>r && v[j].first.first-r+t>=h) {cout<<i<<" "<<r+h-t<<" "<<i<<" "<<n; return 0;}
                        if (v[j].first.first>r) t+=v[j].first.first-r;

                        t+=v[j].first.second-r;
                        r = v[j].first.second;
                        j++;
                    }
              //      cout<<h<< " "<<t<<" "<<r<<" "<<endl;
                    cout<<i<<" "<<r+h-t<<" "<<i<<" "<<n;

                    return 0;
                }

            }
        }
    }
    return 0;
}


#include <iostream>
#include <cstdio>
#include <memory.h>
#include <vector>
#include <set>
#include <string>
#include <cmath>
#include <stdio.h>
#include <algorithm>
#include <queue>
#include <stack>

#define file_name ""

typedef long long ll;
const int N = 1e5+5;
const int oo = 2e9;
const ll loo = 2e18;

#define mp make_pair
using namespace std;

int cmp(pair <pair <int, int >, int > a, pair <pair < int, int >, int > b)
{
    return (a.second<b.second || (a.second==b.second && a.first<b.first));
}

int ans;
ll func(vector <pair <pair <int, int >, int> > &v, int n, int m)
{
    ll d=0,c=0,res=0;
    int len = v.size();
    ll x,y;
    for(int i=0;i<len;++i)
    {
        if (!i || v[i].second != v[i-1].second) {
            c++;
            if (i) res^=(n-d);
        //    cout<<"!!"<<d<<" "<<i<<" "<<v[i].first.second<<" "<<v[i].second<<endl;
            d=0; d+=v[i].first.second-v[i].first.first;}
        else
        {
            x = max(v[i].first.first,v[i-1].first.second);
            y = v[i].first.second;
            d+=y-x;
        }
    }
    if (!v.empty())res^=(n-d);
    //cout<<res<<endl;
    if (c!=m-1 && (m-c-1)%2) res^=n;
    //cout<<res<<" "<<c<<" "<<m<<" "<<(c!=m-1) <<" "<< (m-c-1)%2<<endl;
    return res;
}
int main()
{
    //    freopen(file_name".in","r",stdin);
    //    freopen(file_name".out","w",stdout);
    ll n,m,k;
    cin>>m>>n>>k;
    vector <pair <pair <int, int >, int> > v;
    vector <pair <pair <int, int >, int> > g;
    int x,y,z,d;
    for(int i=0;i<k;++i)
    {
        cin>>x>>y>>z>>d;
        if (x==z) v.push_back(mp(mp(min(y,d),max(y,d)),x));
        else g.push_back(mp(mp(min(x,z),max(x,z)),y));
    }

    sort(v.begin(),v.end(),cmp);
    sort(g.begin(),g.end(),cmp);

    ll a = func(v,n,m)^func(g,m,n);
   // cout<<a<<"!"<<func(v,n,m)<<endl;
    //cout<<b<<endl;
    if (a==0) cout<<"SECOND";
    else
    {
        cout<<"FIRST\n";
        int j=0;
        ll l,r,t;
        if (a<=m)
        {
            for(int i=1;i<=n-1;++i)
            {
                if (j>=g.size() || i!=g[j].second) {cout<<0<<" "<<i<<" "<<a<<" "<<i; return 0;}
                l = g[j].first.first;
                t=0;
                if(l) t = l;
                r = g[j].first.second;
                j++;
                while(j<g.size() && g[j].second==i)
                {
                    if(g[j].first.first>r)
                    {
                        if (g[j].first.first-r+t>=a) {cout<<0<<" "<<i<<" "<<r+a-t<<" "<<i; return 0;}
                        else t+=g[j].first.first-r;
                    }
                    r = g[j].first.second;
                    j++;
                }
                if (r<m && m-r+t>=a){cout<<0<<" "<<i<<" "<<r+m-t<<" "<<i; return 0;}
            }
        }
        if (a<=n)
        {
            t=j=0;
            for(int i=1;i<=m-1;++i)
            {
                if (j>=v.size() || i!=v[j].second) {cout<<i<<" "<<0<<" "<<i<<" "<<a; return 0;}
                l = v[j].first.first;
                t=0;
                if(l) t = l;
                r = v[j].first.second;
                j++;
                while(j<v.size() && v[j].second==i)
                {
                    if(v[j].first.first>r)
                    {
                        if (v[j].first.first-r+t>=a) {cout<<i<<" "<<0<<" "<<i<<" "<<r+a-t; return 0;}
                        else t+=v[j].first.first-r;
                    }
                    r = v[j].first.second;
                    j++;
                }
                if (r<n && n-r+t>=a) {cout<<i<<" "<<0<<" "<<i<<" "<<r+n-t; return 0;}
            }
        }
    }
    return 0;
}


#include <iostream>
#include <cstdio>
#include <memory.h>
#include <vector>
#include <set>
#include <string>
#include <cmath>
#include <stdio.h>
#include <algorithm>
#include <queue>
#include <stack>

#define file_name ""

typedef long long ll;
const int N = 1e5+5;

#define mp make_pair
using namespace std;

int cmp(pair <pair <int, int >, int > a, pair <pair < int, int >, int > b)
{
    return (a.second<b.second || (a.second==b.second && a.first<b.first));
}

int ans;
ll func(vector <pair <pair <int, int >, int> > &v, int n, int m)
{
    ll d=0,c=0,res=0;
    int len = v.size();
    ll x,y;
    for(int i=0;i<len;++i)
    {
        if (!i || v[i].second != v[i-1].second) {
            c++;
            if (i) res^=(n-d);
         //  cout<<"!!"<<d<<" "<<res<<" "<<v[i].first.first<<" "<<v[i].first.second<<" "<<v[i].second<<endl;
            d=0; d+=v[i].first.second-v[i].first.first;
           // cout<<"!!"<<d<<endl;
        }
        else
        {
            x = max(v[i].first.first,v[i-1].first.second);
            y = v[i].first.second;
            if (y>v[i-1].first.second)d+=y-x;
        }
    }
    if (!v.empty())res^=(n-d);
    //cout<<res<<endl;
    if (c!=m-1 && (m-c-1)%2) res^=n;
   // cout<<res<<" "<<c<<" "<<m<<" "<<(c!=m-1) <<" "<< (m-c-1)%2<<endl;
    return res;
}
int main()
{
    //    freopen(file_name".in","r",stdin);
    //    freopen(file_name".out","w",stdout);
    ll n,m,k;
    cin>>m>>n>>k;
    vector <pair <pair <int, int >, int> > v;
    vector <pair <pair <int, int >, int> > g;
    int x,y,z,d;
    for(int i=0;i<k;++i)
    {
        cin>>x>>y>>z>>d;
        if (x==z) v.push_back(mp(mp(min(y,d),max(y,d)),x));
        else g.push_back(mp(mp(min(x,z),max(x,z)),y));
    }

    sort(v.begin(),v.end(),cmp);
    sort(g.begin(),g.end(),cmp);

    ll a = func(v,n,m)^func(g,m,n);
  //  cout<<a<<"!"<<func(v,n,m)<<endl;
    //cout<<b<<endl;
    if (a==0) cout<<"SECOND";
    else
    {
        cout<<"FIRST\n";
        int j=0;
        int l,r,j0;
        ll t =0;
        if (1)
        {
            for(int i=1;i<=n-1;++i)
            {
                j0=j;
                if ((j>=g.size() || i!=g[j].second)) {t = m;}
                else
                {
              //      cout<<i<<" "<<g[j].first.first<<" "<< g[j].first.second<<" "<<g[j].second<< endl;
                    l = g[j].first.first;
                    t=0;
                    if(l) t = l;
                    r = g[j].first.second;
                    t+=r-l;
                    j++;
                    while(j<g.size() && g[j].second==i)
                    {
                        l = max(g[j].first.first,r);
                        r = g[j].first.second;
                        t+=r-l;
                        j++;
                    }

                    t = m-t;
                }
              // cout<<a<<" "<<t<<" "<<g.size()<<" "<<j<<endl;

                if ((a^t)<t)
                {
                    ll h=a^t;
                    h = m-h;
                    j=j0;
                    l=r=0;
                    t=0;
                    if (j<g.size() && i==g[j].second)
                    {
                        l = g[j].first.first;
                        t=0;
                        if(l) t = l;
                        r = g[j].first.second;
                        t+=r-l;
                        j++;
                    }
                 //   cout<<h<<' '<<t<<endl;
                    while(j<g.size() && g[j].second==i)
                    {
                        if(g[j].first.first>r)
                        {
                            if (g[j].first.first-r+t>=h) {cout<<0<<" "<<i<<" "<<r+h-t<<" "<<i; return 0;}
                            else t+=g[j].first.first-r;
                        }
                        r = g[j].first.second;
                        j++;
                    }
                //    cout<<h<<" "<<t<<" "<<r<<endl;
                    cout<<0<<" "<<i<<" "<<r+h-t<<" "<<i;

                    return 0;
                }
            }
        }
        if (1)
        {
            t=j=0;
            for(int i=1;i<=m-1;++i)
            {
                j0=j;
                if ((j>=v.size() || i!=v[j].second)) {t = n;}
                else
                {
                    l = v[j].first.first;
                    t=0;
                    if(l) t = l;

                    r = v[j].first.second;
                    t+=r-l;
                    j++;
                    while(j<v.size() && v[j].second==i)
                    {
                        l = max(v[j].first.first,r);
                        r = v[j].first.second;
                        t+=r-l;
                        j++;
                    }

                    t = n-t;
                }
                if ((a^t)<t)
                {

                    ll h=a^t;
                    h = n-h;
                    j=j0;
                    t=0;
                    l=r=0;
                    if (j<v.size() && v[j].second==i)
                    {
                        l = v[j].first.first;
                        if(l) t = l;
                        r = v[j].first.second;
                        t+=r-l;
                        j++;
                    }
                    while(j<v.size() && v[j].second==i)
                    {

                        if(v[j].first.first>r)
                        {
                            if (v[j].first.first-r+t>=h) {cout<<i<<" "<<0<<" "<<i<<" "<<r+h-t; return 0;}
                            else t+=v[j].first.first-r;
                        }
                        r = v[j].first.second;
                        j++;
                    }
                    cout<<i<<" "<<0<<" "<<i<<" "<<r+h-t;

                    return 0;
                }

            }
        }
    }
    return 0;
}


#include <iostream>
#include <cstdio>
#include <memory.h>
#include <vector>
#include <set>
#include <string>
#include <cmath>
#include <stdio.h>
#include <algorithm>
#include <queue>
#include <stack>

#define file_name ""

typedef long long ll;
const int N = 1e5+5;

#define mp make_pair
using namespace std;

int cmp(pair <pair <int, int >, int > a, pair <pair < int, int >, int > b)
{
    return (a.second<b.second || (a.second==b.second && a.first<b.first));
}

int ans;
ll func(vector <pair <pair <int, int >, int> > &v, int n, int m)
{
    ll d=0,c=0,res=0;
    int len = v.size();
    ll x,y;
    for(int i=0;i<len;++i)
    {
        if (!i || v[i].second != v[i-1].second) {
            c++;
            if (i) res^=(n-d);
         //  cout<<"!!"<<d<<" "<<res<<" "<<v[i].first.first<<" "<<v[i].first.second<<" "<<v[i].second<<endl;
            d=0; d+=v[i].first.second-v[i].first.first;
           // cout<<"!!"<<d<<endl;
        }
        else
        {
            x = max(v[i].first.first,v[i-1].first.second);
            y = v[i].first.second;
            if (y>v[i-1].first.second)d+=y-x;
        }
    }
    if (!v.empty())res^=(n-d);
    //cout<<res<<endl;
    if (c!=m-1 && (m-c-1)%2) res^=n;
   // cout<<res<<" "<<c<<" "<<m<<" "<<(c!=m-1) <<" "<< (m-c-1)%2<<endl;
    return res;
}
int main()
{
    //    freopen(file_name".in","r",stdin);
    //    freopen(file_name".out","w",stdout);
    ll n,m,k;
    cin>>m>>n>>k;
    vector <pair <pair <int, int >, int> > v;
    vector <pair <pair <int, int >, int> > g;
    int x,y,z,d;
    for(int i=0;i<k;++i)
    {
        cin>>x>>y>>z>>d;
        if (x==z) v.push_back(mp(mp(min(y,d),max(y,d)),x));
        else g.push_back(mp(mp(min(x,z),max(x,z)),y));
    }

    sort(v.begin(),v.end(),cmp);
    sort(g.begin(),g.end(),cmp);

    ll a = func(v,n,m)^func(g,m,n);
  //  cout<<a<<"!"<<func(v,n,m)<<endl;
    //cout<<b<<endl;
    if (a==0) cout<<"SECOND";
    else
    {
        cout<<"FIRST\n";
        int j=0;
        int l,r,j0;
        ll t =0;
        if (1)
        {
            for(int i=1;i<=n-1;++i)
            {
                j0=j;
                if ((j>=g.size() || i!=g[j].second)) {t = m;}
                else
                {
              //      cout<<i<<" "<<g[j].first.first<<" "<< g[j].first.second<<" "<<g[j].second<< endl;
                    l = g[j].first.first;
                    t=0;
                    r = g[j].first.second;
                    t+=r-l;
                    j++;
                    while(j<g.size() && g[j].second==i)
                    {
                        l = max(g[j].first.first,r);
                        r = g[j].first.second;
                        t+=r-l;
                        j++;
                    }

                    t = m-t;
                }
              // cout<<a<<" "<<t<<" "<<g.size()<<" "<<j<<endl;

                if ((a^t)<t)
                {
                    ll h=a^t;
                    h = m-h;
                    if (h<0) continue;
                    //cout<<a<<' '<<h<<" "<<t<<endl;
                    j=j0;
                    l=r=0;
                    t=0;

                    if (j<g.size() && i==g[j].second)
                    {
                        l = g[j].first.first;
                        t=0;
                        r = g[j].first.second;
                        t=r;
                        j++;
                    }
                 //   cout<<h<<' '<<t<<endl;
                    while(j<g.size() && g[j].second==i)
                    {
                        if(g[j].first.first>r)
                        {
                            if (g[j].first.second-r+t>=h) {cout<<0<<" "<<i<<" "<<r+h-t<<" "<<i; return 0;}
                            else t+=g[j].first.second-r;
                        }
                        r = g[j].first.second;
                        j++;
                    }
                //    cout<<h<<" "<<t<<" "<<r<<endl;
                    cout<<0<<" "<<i<<" "<<r+h-t<<" "<<i;

                    return 0;
                }
            }
        }
        if (1)
        {
            t=j=0;
            for(int i=1;i<=m-1;++i)
            {
                j0=j;
                if ((j>=v.size() || i!=v[j].second)) {t = n;}
                else
                {
                    l = v[j].first.first;
                    t=0;
                    //if(l) t = l;

                    r = v[j].first.second;
                    t+=r-l;
                    j++;
                    while(j<v.size() && v[j].second==i)
                    {
                        l = max(v[j].first.first,r);
                        r = v[j].first.second;
                        t+=r-l;
                        j++;
                    }

                    t = n-t;
                }
                if ((a^t)<t)
                {

                    ll h=a^t;
                    h = n-h;
                    if (h<0) continue;
                    j=j0;
                    t=0;
                    l=r=0;
                    if (j<v.size() && v[j].second==i)
                    {
                        l = v[j].first.first;

                        r = v[j].first.second;
                        t=r;
                        j++;
                    }
                    while(j<v.size() && v[j].second==i)
                    {

                        if(v[j].first.first>r)
                        {
                            if (v[j].first.second-r+t>=h) {cout<<i<<" "<<0<<" "<<i<<" "<<r+h-t; return 0;}
                            else t+=v[j].first.second-r;
                        }
                        r = v[j].first.second;
                        j++;
                    }
              //      cout<<h<< " "<<t<<" "<<r<<" "<<endl;
                    cout<<i<<" "<<0<<" "<<i<<" "<<r+h-t;

                    return 0;
                }

            }
        }
    }
    return 0;
}


#include <iostream>
#include <cstdio>
#include <memory.h>
#include <vector>
#include <set>
#include <string>
#include <cmath>
#include <stdio.h>
#include <algorithm>
#include <queue>
#include <stack>

#define file_name ""

typedef long long ll;
const int N = 1e5+5;

#define mp make_pair
using namespace std;

int cmp(pair <pair <int, int >, int > a, pair <pair < int, int >, int > b)
{
    return (a.second<b.second || (a.second==b.second && a.first<b.first));
}

int ans;
ll func(vector <pair <pair <int, int >, int> > &v, int n, int m)
{
    ll d=0,c=0,res=0;
    int len = v.size();
    ll x,y;
    for(int i=0;i<len;++i)
    {
        if (!i || v[i].second != v[i-1].second) {
            c++;
            if (i) res^=(n-d);
        //   cout<<"!!"<<d<<" "<<res<<" "<<v[i].first.first<<" "<<v[i].first.second<<" "<<v[i].second<<endl;
            d=0; d+=v[i].first.second-v[i].first.first;
            y = v[i].first.second;
            x = v[i].first.first;
        //    cout<<"!!"<<d<<" "<<i<<endl;
        }
        else
        {
            x = max((ll)v[i].first.first,max(x,y));
            y = v[i].first.second;
     //       cout<<x<<"  !!!     "<<y<<endl;
            if (y>x)d+=y-x;
        }
    }
    if (!v.empty())res^=(n-d);
   // cout<<res<<endl;
    if (c!=m-1 && (m-c-1)%2) res^=n;
  //  cout<<res<<" "<<c<<" "<<m<<" "<<(c!=m-1) <<" "<< (m-c-1)%2<<endl;
    return res;
}
int main()
{
    //    freopen(file_name".in","r",stdin);
    //    freopen(file_name".out","w",stdout);
    ll n,m,k;
    cin>>m>>n>>k;
    vector <pair <pair <int, int >, int> > v;
    vector <pair <pair <int, int >, int> > g;
    int x,y,z,d;
    for(int i=0;i<k;++i)
    {
        cin>>x>>y>>z>>d;
        if (x==z) v.push_back(mp(mp(min(y,d),max(y,d)),x));
        else g.push_back(mp(mp(min(x,z),max(x,z)),y));
    }

    sort(v.begin(),v.end(),cmp);
    sort(g.begin(),g.end(),cmp);

    ll a = func(v,n,m)^func(g,m,n);

   // cout<<"====\n";
   //cout<<a<<"!"<<func(g,m,n)<<endl;
    //cout<<b<<endl;
    if (a==0) cout<<"SECOND";
    else
    {
        cout<<"FIRST\n";
        int j=0;
        int l,r,j0;
        ll t =0;
        if (1)
        {
            for(int i=1;i<=n-1;++i)
            {
                j0=j;
                if ((j>=g.size() || i!=g[j].second)) {t = m;}
                else
                {
              //      cout<<i<<" "<<g[j].first.first<<" "<< g[j].first.second<<" "<<g[j].second<< endl;
                    l = g[j].first.first;
                    t=0;
                    r = g[j].first.second;
                    t+=r-l;
                    j++;
                    while(j<g.size() && g[j].second==i)
                    {
                        l = max(g[j].first.first,r);
                        r = g[j].first.second;
                        t+=r-l;
                        j++;
                    }

                    t = m-t;
                }
              // cout<<a<<" "<<t<<" "<<g.size()<<" "<<j<<endl;

                if ((a^t)<t)
                {
                    ll h=a^t;
                  //  cout<<a<<' '<<h<<" "<<t<<endl;
                    j=j0;
                    l=r=0;
                    t=0;

                    if (j<g.size() && i==g[j].second)
                    {
                        l = g[j].first.first;
                        t = (l?l:0);
                        r = g[j].first.second;

                        if (t>=h) {cout<<h<<" "<<i<<" "<<m<<" "<<i; return 0;}
                        j++;
                    }
                 //   cout<<h<<' '<<t<<endl;
                    while(j<g.size() && g[j].second==i)
                    {
                        if (g[j].first.first>r && g[j].first.first-r+t>=h) {cout<<r+h-t<<" "<<i<<" "<<m<<" "<<i; return 0;}
                        if (g[j].first.first>r) t+=g[j].first.first-r;
                        r = g[j].first.second;
                        j++;
                    }
                  //  cout<<h<<" "<<t<<" "<<r<<endl;
                    cout<<r+h-t<<" "<<i<<" "<<m<<" "<<i;

                    return 0;
                }
            }
        }
        if (1)
        {
            t=j=0;
            for(int i=1;i<=m-1;++i)
            {
                j0=j;
                if ((j>=v.size() || i!=v[j].second)) {t = n;}
                else
                {
                    l = v[j].first.first;
                    t=0;
                    r = v[j].first.second;
                    t+=r-l;
                    j++;
                    while(j<v.size() && v[j].second==i)
                    {
                        l = max(v[j].first.first,r);
                        r = v[j].first.second;
                        t+=r-l;
                        j++;
                    }

                    t = n-t;
                }
                if ((a^t)<t)
                {

                    ll h=a^t;
                    if (h<0) continue;
                    j=j0;
                    t=0;
                    l=r=0;
                    if (j<v.size() && v[j].second==i)
                    {
                        l = v[j].first.first;

                        r = v[j].first.second;

                         t = (l?l:0);
                        if (t>=h) {cout<<i<<" "<<h<<" "<<i<<" "<<n; return 0;}
                        j++;
                    }
                    while(j<v.size() && v[j].second==i)
                    {
                        if (v[j].first.first>r && v[j].first.first-r+t>=h) {cout<<i<<" "<<r+h-t<<" "<<i<<" "<<n; return 0;}
                        if (v[j].first.first>r) t+=v[j].first.first-r;

                        t+=v[j].first.second-r;
                        r = v[j].first.second;
                        j++;
                    }
              //      cout<<h<< " "<<t<<" "<<r<<" "<<endl;
                    cout<<i<<" "<<r+h-t<<" "<<i<<" "<<n;

                    return 0;
                }

            }
        }
    }
    return 0;
}


#include <iostream>
#include <cstdio>
#include <memory.h>
#include <vector>
#include <set>
#include <string>
#include <cmath>
#include <stdio.h>
#include <algorithm>
#include <queue>
#include <stack>

#define file_name ""

typedef long long ll;
const int N = 1e5+5;

#define mp make_pair
using namespace std;

int cmp(pair <pair <int, int >, int > a, pair <pair < int, int >, int > b)
{
    return (a.second<b.second || (a.second==b.second && a.first<b.first));
}

int ans;
ll func(vector <pair <pair <int, int >, int> > &v, int n, int m)
{
    ll d=0,c=0,res=0;
    int len = v.size();
    ll x,y;
    for(int i=0;i<len;++i)
    {
        if (!i || v[i].second != v[i-1].second) {
            c++;
            if (i) res^=(n-d);
        //   cout<<"!!"<<d<<" "<<res<<" "<<v[i].first.first<<" "<<v[i].first.second<<" "<<v[i].second<<endl;
            d=0; d+=v[i].first.second-v[i].first.first;
            y = v[i].first.second;
            x = v[i].first.first;
        //    cout<<"!!"<<d<<" "<<i<<endl;
        }
        else
        {
            x = max((ll)v[i].first.first,max(x,y));
            y = v[i].first.second;
     //       cout<<x<<"  !!!     "<<y<<endl;
            if (y>x)d+=y-x;
        }
    }
    if (!v.empty())res^=(n-d);
   // cout<<res<<endl;
    if (c!=m-1 && (m-c-1)%2) res^=n;
  //  cout<<res<<" "<<c<<" "<<m<<" "<<(c!=m-1) <<" "<< (m-c-1)%2<<endl;
    return res;
}
int main()
{
    //    freopen(file_name".in","r",stdin);
    //    freopen(file_name".out","w",stdout);
    ll n,m,k;
    cin>>m>>n>>k;
    vector <pair <pair <int, int >, int> > v;
    vector <pair <pair <int, int >, int> > g;
    int x,y,z,d;
    for(int i=0;i<k;++i)
    {
        cin>>x>>y>>z>>d;
        if (x==z) v.push_back(mp(mp(min(y,d),max(y,d)),x));
        else g.push_back(mp(mp(min(x,z),max(x,z)),y));
    }

    sort(v.begin(),v.end(),cmp);
    sort(g.begin(),g.end(),cmp);

    ll a = func(v,n,m)^func(g,m,n);

   // cout<<"====\n";
   //cout<<a<<"!"<<func(g,m,n)<<endl;
    //cout<<b<<endl;
    if (a==0) cout<<"SECOND";
    else
    {
        cout<<"FIRST\n";
        int j=0;
        int l,r,j0;
        ll t =0;
        if (1)
        {
            for(int i=1;i<=min(n-1,100005LL);++i)
            {
                j0=j;
                if ((j>=g.size() || i!=g[j].second)) {t = m;}
                else
                {
              //      cout<<i<<" "<<g[j].first.first<<" "<< g[j].first.second<<" "<<g[j].second<< endl;
                    l = g[j].first.first;
                    t=0;
                    r = g[j].first.second;
                    t+=r-l;
                    j++;
                    while(j<g.size() && g[j].second==i)
                    {
                        l = max(g[j].first.first,max(l,r));
                        r = g[j].first.second;
                        if (r>l) t+=r-l;
                        j++;
                    }

                    t = m-t;
                }
              // cout<<a<<" "<<t<<" "<<g.size()<<" "<<j<<endl;

                if ((a^t)<t)
                {
                    ll h=a^t;
                  //  cout<<a<<' '<<h<<" "<<t<<endl;
                    j=j0;
                    l=r=0;
                    t=0;

                    if (j<g.size() && i==g[j].second)
                    {
                        l = g[j].first.first;
                        t = (l?l:0);
                         r = g[j].first.second;

                        if (t>=h) {cout<<h<<" "<<i<<" "<<m<<" "<<i; return 0;}
                        j++;
                    }
                 //   cout<<h<<' '<<t<<endl;
                    while(j<g.size() && g[j].second==i)
                    {

                        if (g[j].first.first>r && g[j].first.first-r+t>=h) {cout<<r+h-t<<" "<<i<<" "<<m<<" "<<i; return 0;}
                        if ( g[j].first.first>r) t+=g[j].first.first-r;
                        r = max(g[j].first.second,r);
                        j++;
                    }
                  //  cout<<h<<" "<<t<<" "<<r<<endl;
                    cout<<r+h-t<<" "<<i<<" "<<m<<" "<<i;

                    return 0;
                }
            }
        }
        if (1)
        {
            t=j=0;
            for(int i=1;i<=min(m-1,100005LL);++i)
            {
                j0=j;
                if ((j>=v.size() || i!=v[j].second)) {t = n;}
                else
                {
                    l = v[j].first.first;
                    t=0;
                    r = v[j].first.second;
                    t+=r-l;
                    j++;
                    while(j<v.size() && v[j].second==i)
                    {
                        l = max(v[j].first.first,max(l,r));
                        r = v[j].first.second;
                        if (r>l) t+=r-l;
                        j++;
                    }

                    t = n-t;
                }
                if ((a^t)<t)
                {

                    ll h=a^t;
                    if (h<0) continue;
                    j=j0;
                    t=0;
                    l=r=0;
                    if (j<v.size() && v[j].second==i)
                    {
                        l = v[j].first.first;

                        r = v[j].first.second;

                         t = (l?l:0);

                        if (t>=h) {cout<<i<<" "<<h<<" "<<i<<" "<<n; return 0;}
                        j++;
                    }
                    while(j<v.size() && v[j].second==i)
                    {
                        if (v[j].first.first>r && v[j].first.first-r+t>=h) {cout<<i<<" "<<r+h-t<<" "<<i<<" "<<n; return 0;}
                        if ( v[j].first.first>r) t+=v[j].first.first-r;

                        r = max(r,v[j].first.second);
                        j++;
                    }
              //      cout<<h<< " "<<t<<" "<<r<<" "<<endl;
                    cout<<i<<" "<<r+h-t<<" "<<i<<" "<<n;

                    return 0;
                }

            }
        }
    }
    return 0;
}


#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>
#include <cstring>
#include <cmath>
#include <set>
#include <map>
#include <cstdio>
#include <stdlib.h>
#include <stack>
#include <numeric>
#include <bitset>
#include <cctype>
#include <list>
#include <assert.h>

typedef long long ll;
#define MAX 100005
using namespace std;
#define INF 2147483647
#define inf (1<<30)
#define MOD 1000000007
#define EPS 1e-9
#define G 9.8
#define PI acos(-1)
#define REP(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define REQ(i,n) for(int (i)=1;(i)<=(int)(n);(i)++)
#define lch rt<<1
#define rch rt<<1|1
bool debug = false;
int n,m, k;
int dx[4] = {1,0,-1,0}, dy[4] = {0,1,0,-1};
ll ln, lk, lm;

int f[MAX], X[MAX], Y[MAX],root;
struct node {
    int l,r;
    vector<int> q;
}T[MAX];
int ff(int x) {
    return x==f[x] ? x : f[x]=ff(f[x]);
}
int cnt, S;
void join(int &rt, int l, int r, int x) {
    if (rt == 0) return;
    for(int c : T[rt].q) {
        int fc = ff(c);
        X[cnt] = min(X[cnt], X[fc]);
        Y[cnt] = max(Y[cnt], Y[fc]);
        f[fc] = cnt;
    }
    T[rt].q.clear();
    int mid = (l+r)/2;
    if (l==r) return;
    if (x<=mid) join(T[rt].l, l, mid, x);
    else join(T[rt].r, mid+1, r, x);
}
void update(int &rt, int l, int r, int L, int R) {
    if(rt==0) rt=++S;
    if (S>1e6) {
        cout<<cnt<<endl;
        exit(0);
    }
    if (r<=R && L<=l) {
        T[rt].q.push_back(cnt); return;
    }
    int mid = (l+r)/2;
    if(R<=mid) update(T[rt].l, l, mid, L, R);
    else if (mid<L) {
        update(T[rt].r, mid+1, r, L, R);
    } else {
        update(T[rt].l, l, mid, L, mid);
        update(T[rt].r, mid+1, r, mid+1, R);
    }
}
int main(){
    scanf("%d", &n);
    for(int i=0,u,v,t;i<n;i++) {
        scanf("%d%d%d", &t, &u, &v);
        if (t==1) {
            ++cnt;
            X[cnt] = u; Y[cnt] = v;
            f[cnt] = cnt;
            join(root, -1e9, 1e9, u);
            join(root, -1e9, 1e9, v);
            if (X[cnt]+1 < Y[cnt]) {
                update(root, -1e9, 1e9, X[cnt]+1, Y[cnt]-1);
            }
        } else {
            int fu = ff(u), fv=ff(v);
            if (fu==fv) puts("YES");
            else if (X[fu] >= X[fv] && Y[fu] <= Y[fv]
                     && !(X[fu] == X[fv] && Y[fu] == Y[fv])) {
                puts("YES");
            } else puts("NO");
        }
    }
    return 0;
}


#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>
#include <cstring>
#include <cmath>
#include <set>
#include <map>
#include <cstdio>
#include <stdlib.h>
#include <stack>
#include <numeric>
#include <bitset>
#include <cctype>
#include <list>
#include <assert.h>

typedef long long ll;
#define MAX 100005
using namespace std;
#define INF 2147483647
#define inf (1<<30)
#define MOD 1000000007
#define EPS 1e-9
#define G 9.8
#define PI acos(-1)
#define REP(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define REQ(i,n) for(int (i)=1;(i)<=(int)(n);(i)++)
#define lch rt<<1
#define rch rt<<1|1
bool debug = false;
int n,m, k;
int dx[4] = {1,0,-1,0}, dy[4] = {0,1,0,-1};
ll ln, lk, lm;

int f[MAX], X[MAX], Y[MAX],root;
struct node {
    int l,r;
    vector<int> q;
}T[MAX];
int cnt, S;
int jc=0;
int ff(int x) {
    jc++;
    if (jc>1e6) {
        cout<<cnt<<endl;
        cout<<x<<endl;
        exit(0);
    }
    return x==f[x] ? x : f[x]=ff(f[x]);
}

void join(int &rt, int l, int r, int x) {
    if (rt == 0) return;
    jc++;
    if (jc>1e6) {
        cout<<cnt<<endl;
        cout<<l<<" "<<r<<endl;
        exit(0);
    }
    for(int c : T[rt].q) {
        int fc = ff(c);
        X[cnt] = min(X[cnt], X[fc]);
        Y[cnt] = max(Y[cnt], Y[fc]);
        f[fc] = cnt;
    }
    T[rt].q.clear();
    int mid = (l+r)/2;
    if (l==r) return;
    if (x<=mid) join(T[rt].l, l, mid, x);
    else join(T[rt].r, mid+1, r, x);
}
void update(int &rt, int l, int r, int L, int R) {
    if(rt==0) rt=++S;

    if (r<=R && L<=l) {
        T[rt].q.push_back(cnt); return;
    }
    int mid = (l+r)/2;
    if(R<=mid) update(T[rt].l, l, mid, L, R);
    else if (mid<L) {
        update(T[rt].r, mid+1, r, L, R);
    } else {
        update(T[rt].l, l, mid, L, mid);
        update(T[rt].r, mid+1, r, mid+1, R);
    }
}
int main(){
    scanf("%d", &n);
    for(int i=0,u,v,t;i<n;i++) {
        scanf("%d%d%d", &t, &u, &v);
        if (t==1) {
            ++cnt;
            X[cnt] = u; Y[cnt] = v;
            f[cnt] = cnt;
            join(root, -1e9, 1e9, u);
            join(root, -1e9, 1e9, v);
            if (X[cnt]+1 < Y[cnt]) {
                update(root, -1e9, 1e9, X[cnt]+1, Y[cnt]-1);
            }
        } else {
            int fu = ff(u), fv=ff(v);
            if (fu==fv) puts("YES");
            else if (X[fu] >= X[fv] && Y[fu] <= Y[fv]
                     && !(X[fu] == X[fv] && Y[fu] == Y[fv])) {
                puts("YES");
            } else puts("NO");
        }
    }
    return 0;
}


#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>
#include <cstring>
#include <cmath>
#include <set>
#include <map>
#include <cstdio>
#include <stdlib.h>
#include <stack>
#include <numeric>
#include <bitset>
#include <cctype>
#include <list>
#include <assert.h>

typedef long long ll;
#define MAX 100005
using namespace std;
#define INF 2147483647
#define inf (1<<30)
#define MOD 1000000007
#define EPS 1e-9
#define G 9.8
#define PI acos(-1)
#define REP(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define REQ(i,n) for(int (i)=1;(i)<=(int)(n);(i)++)
#define lch rt<<1
#define rch rt<<1|1
bool debug = false;
int n,m, k;
int dx[4] = {1,0,-1,0}, dy[4] = {0,1,0,-1};
ll ln, lk, lm;

int f[MAX], X[MAX], Y[MAX],root;
struct node {
    int l,r;
    vector<int> q;
}T[MAX * 40];
int ff(int x) {
    return x==f[x] ? x : f[x]=ff(f[x]);
}
int cnt, S;
void join(int &rt, int l, int r, int x) {
    if (rt == 0) return;
    for(int c : T[rt].q) {
        int fc = ff(c);
        X[cnt] = min(X[cnt], X[fc]);
        Y[cnt] = max(Y[cnt], Y[fc]);
        f[fc] = cnt;
    }
    T[rt].q.clear();
    int mid = (l+r)/2;
    if (l==r) return;
    if (x<=mid) join(T[rt].l, l, mid, x);
    else join(T[rt].r, mid+1, r, x);
}
void update(int &rt, int l, int r, int L, int R) {
    if(rt==0) rt=++S;
    if (r<=R && L<=l) {
        T[rt].q.push_back(cnt); return;
    }
    int mid = (l+r)/2;
    if(R<=mid) update(T[rt].l, l, mid, L, R);
    else if (mid<L) {
        update(T[rt].r, mid+1, r, L, R);
    } else {
        update(T[rt].l, l, mid, L, mid);
        update(T[rt].r, mid+1, r, mid+1, R);
    }
}
int main(){
    scanf("%d", &n);
    for(int i=0,u,v,t;i<n;i++) {
        scanf("%d%d%d", &t, &u, &v);
        if (t==1) {
            ++cnt;
            X[cnt] = u; Y[cnt] = v;
            f[cnt] = cnt;
            join(root, -1e9, 1e9, u);
            join(root, -1e9, 1e9, v);
            if (X[cnt]+1 < Y[cnt]) {
                update(root, -1e9, 1e9, X[cnt]+1, Y[cnt]-1);
            }
        } else {
            int fu = ff(u), fv=ff(v);
            if (fu==fv) puts("YES");
            else if (X[fu] >= X[fv] && Y[fu] <= Y[fv]
                     && !(X[fu] == X[fv] && Y[fu] == Y[fv])) {
                puts("YES");
            } else puts("NO");
        }
    }
    return 0;
}


/*
{
######################
#       Author       #
#        Gary        #
#        2020        #
######################
*/
//#pragma GCC target ("avx2")
//#pragma GCC optimization ("O3")
//#pragma GCC optimization ("unroll-loops")
#pragma GCC optimize(2)
#include<bits/stdc++.h>
#define rb(a,b,c) for(int a=b;a<=c;++a)
#define rl(a,b,c) for(int a=b;a>=c;--a)
#define LL long long
#define IT iterator
#define PB push_back
#define II(a,b) make_pair(a,b)
#define FIR first
#define SEC second
#define FREO freopen("check.out","w",stdout)
#define rep(a,b) for(int a=0;a<b;++a)
#define SRAND mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#define random(a) rng()%a
#define ALL(a) a.begin(),a.end()
#define POB pop_back
#define ff fflush(stdout)
#define fastio ios::sync_with_stdio(false)
#define R(a) a=read()
#define R2(a,b) a=read(),b=read()
#define check_min(a,b) a=min(a,b)
#define check_max(a,b) a=max(a,b)
using namespace std;
const int INF=0x3f3f3f3f;
typedef pair<int,int> mp;

/*}
*/
inline int read(){
    int x=0;
    char ch=getchar();
    while(ch<'0'||ch>'9'){
        ch=getchar();
    }
    while(ch>='0'&&ch<='9'){
        x=(x<<1)+(x<<3)+(ch^48);
        ch=getchar();
    }
    return x;
}
inline void write(int x)
{
    if(x>9) write(x/10);
    putchar(x%10+'0');
}
int n;
const int MAXN=1e5+20;
struct DSU{
	int fa[MAXN],l[MAXN],r[MAXN];
	void init(){
		rb(i,1,n) l[i]=INF,r[i]=-INF,fa[i]=i;
	}
	int root(int x){
		return fa[x]=(fa[x]==x? x:root(fa[x]));
	}
	void merge(int u,int v){
		u=root(u);
		v=root(v);
		fa[u]=v;
		check_min(l[v],l[u]);
		check_max(r[v],r[u]);
	}
	void Set(int id,int ll_,int rr_){
		id=root(id);
		check_min(l[id],ll_);
		check_max(r[id],rr_);
	}
	bool query(int x,int y){
		if(root(x)==root(y)) return true;
		x=root(x);
		y=root(y);
//		cout<<root(x)<<' '<<root(y)<<'!'<<endl;
		if((l[x]>=l[y]&&r[x]<=r[y])&&(l[x]>l[y]||r[x]<r[y])) return true;
		return false;
	}
}dsu;
const int N=1<<18;
struct SEGMENT_TREE{
	vector<int> node[N+N];
	void add_seg(int a,int b,int id,int now=1,int l=1,int r=N+1){
		if(r<=a||l>=b) return;
		if(r<=b&&l>=a){
			node[now].PB(id);return;
		}
		int mid=(l+r)>>1;
		add_seg(a,b,id,now<<1,l,mid);
		add_seg(a,b,id,now<<1|1,mid,r);
	}
	void process(int id,int merge_to){
		id+=N-1;
		while(id){
			for(auto it:node[id]){
				dsu.merge(it,merge_to);
//				cout<<id<<" "<<it<<' '<<merge_to<<endl;
			}
			node[id].clear();
			id>>=1;
		}
	}
	void add_a_new_segment(int id){
		id=dsu.root(id);
		add_seg(dsu.l[id],dsu.r[id]+1,id);
	}
}sgt;
map<int,int> M;
int t[MAXN],a[MAXN],b[MAXN];
int main(){
	R(n);
	int cnt=0;
	rb(i,1,n)
	{
		R(t[i]),R2(a[i],b[i]);
		if(t[i]==1) b[i]--;
		M[a[i]]=M[b[i]]=true;
	}
	dsu.init();
	for(auto ite=M.begin();ite!=M.end();ite++) ite->SEC=++cnt;
	rb(i,1,n)
		if(t[i]==1) a[i]=M[a[i]],b[i]=M[b[i]];
	cnt=0;
	rb(i,1,n)
	{
		int ty;
		ty=t[i];
		int x,y;
		x=a[i],y=b[i];
		if(ty==1){
			++cnt;
			sgt.process(y,cnt);
			sgt.process(x,cnt);
			dsu.Set(cnt,x,y);
			sgt.add_a_new_segment(cnt);
		}
		else{
			if(dsu.query(x,y)) puts("YES");
			else puts("NO");
		}
	}

	return 0;
}
/** 程序框架：
  *
  *
  *
  *
  **/


/*
{
######################
#       Author       #
#        Gary        #
#        2020        #
######################
*/
//#pragma GCC target ("avx2")
//#pragma GCC optimization ("O3")
//#pragma GCC optimization ("unroll-loops")
#pragma GCC optimize(2)
#include<bits/stdc++.h>
#define rb(a,b,c) for(int a=b;a<=c;++a)
#define rl(a,b,c) for(int a=b;a>=c;--a)
#define LL long long
#define IT iterator
#define PB push_back
#define II(a,b) make_pair(a,b)
#define FIR first
#define SEC second
#define FREO freopen("check.out","w",stdout)
#define rep(a,b) for(int a=0;a<b;++a)
#define SRAND mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#define random(a) rng()%a
#define ALL(a) a.begin(),a.end()
#define POB pop_back
#define ff fflush(stdout)
#define fastio ios::sync_with_stdio(false)
#define R(a) a=read()
#define R2(a,b) a=read(),b=read()
#define check_min(a,b) a=min(a,b)
#define check_max(a,b) a=max(a,b)
using namespace std;
const int INF=0x3f3f3f3f;
typedef pair<int,int> mp;

/*}
*/
inline int read(){
    int x=0;
    char ch=getchar();
    while(ch<'0'||ch>'9'){
        ch=getchar();
    }
    while(ch>='0'&&ch<='9'){
        x=(x<<1)+(x<<3)+(ch^48);
        ch=getchar();
    }
    return x;
}
inline void write(int x)
{
    if(x>9) write(x/10);
    putchar(x%10+'0');
}
int n;
const int MAXN=1e5+20;
struct DSU{
	int fa[MAXN],l[MAXN],r[MAXN];
	void init(){
		rb(i,1,n) l[i]=INF,r[i]=-INF,fa[i]=i;
	}
	int root(int x){
		return fa[x]=(fa[x]==x? x:root(fa[x]));
	}
	void merge(int u,int v){
		u=root(u);
		v=root(v);
		fa[u]=v;
		check_min(l[v],l[u]);
		check_max(r[v],r[u]);
	}
	void Set(int id,int ll_,int rr_){
		id=root(id);
		check_min(l[id],ll_);
		check_max(r[id],rr_);
	}
	bool query(int x,int y){
		if(root(x)==root(y)) return true;
		x=root(x);
		y=root(y);
		if((l[x]>=l[y]&&r[x]<=r[y])&&(l[x]>l[y]||r[x]<r[y])) return true;
		return false;
	}
}dsu;
const int N=1<<18;
struct SEGMENT_TREE{
	vector<int> node[N+N];
	void add_seg(int a,int b,int id,int now=1,int l=1,int r=N+1){
		if(r<=a||l>=b) return;
		if(r<=b&&l>=a){
			node[now].PB(id);return;
		}
		int mid=(l+r)>>1;
		add_seg(a,b,id,now<<1,l,mid);
		add_seg(a,b,id,now<<1|1,mid,r);
	}
	void process(int id,int merge_to){
		id+=N-1;
		while(id){
			for(auto it:node[id]){
				dsu.merge(it,merge_to);
			}
			node[id].clear();
			id>>=1;
		}
	}
	void add_a_new_segment(int id){
		id=dsu.root(id);
		if(dsu.l[id]+1!=dsu.r[id])
		add_seg(dsu.l[id]+1,dsu.r[id],id);
	}
}sgt;
map<int,int> M;
int t[MAXN],a[MAXN],b[MAXN];
int main(){
	R(n);
	int cnt=0;
	rb(i,1,n)
	{
		R(t[i]),R2(a[i],b[i]);
		M[a[i]]=M[b[i]]=true;
	}
	if(n==100) rb(i,50,100) cout<<t[i]<<' '<<a[i]<<' '<<b[i]<<endl;
	dsu.init();
	for(auto ite=M.begin();ite!=M.end();ite++) ite->SEC=++cnt;
	rb(i,1,n)
		if(t[i]==1) a[i]=M[a[i]],b[i]=M[b[i]];
	cnt=0;
	int cntq=0;
	rb(i,1,n)
	{
		int ty;
		ty=t[i];
		int x,y;
		x=a[i],y=b[i];
		if(ty==1){
			++cnt;
			sgt.process(y,cnt);
			sgt.process(x,cnt);
			dsu.Set(cnt,x,y);
			sgt.add_a_new_segment(cnt);
		}
		else{
//			cerr<<"#:"<<++cntq<<" ";
			if(dsu.query(x,y)) puts("YES");
			else puts("NO");
		}
	}

	return 0;
}
/** 程序框架：
  *
  *
  *
  *
  **/


/*
{
######################
#       Author       #
#        Gary        #
#        2020        #
######################
*/
#pragma GCC optimize(2)
#include<bits/stdc++.h>
#define rb(a,b,c) for(int a=b;a<=c;++a)
#define rl(a,b,c) for(int a=b;a>=c;--a)
#define LL long long
#define IT iterator
#define PB push_back
#define II(a,b) make_pair(a,b)
#define FIR first
#define SEC second
#define FREO freopen("check.out","w",stdout)
#define rep(a,b) for(int a=0;a<b;++a)
#define SRAND mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#define random(a) rng()%a
#define ALL(a) a.begin(),a.end()
#define POB pop_back
#define ff fflush(stdout)
#define fastio ios::sync_with_stdio(false)
#define R(a) cin>>a
#define R2(a,b) cin>>a>>b
#define check_min(a,b) a=min(a,b)
#define check_max(a,b) a=max(a,b)
using namespace std;
const int INF=0x3f3f3f3f;
typedef pair<int,int> mp;
/*}
*/
const int MAXN=100000+20;
int fa[MAXN];
int root(int u){
	return fa[u]=(fa[u]==u? u:root(fa[u]));
}
void merge(int u,int v){
	u=root(u);
	v=root(v);
	fa[u]=v;
}
int n;
set<pair<mp,int> > s;//r-l
int main(){
	fastio;
	cin>>n;
	int cnt=0;
	rb(i,1,n)
		fa[i]=i;
	rb(i,1,n){
		int ty;
		R(ty);
		if(ty==1){
			++cnt;
			int x,y;
			R2(x,y);
			int l=x,r=y;
			auto ite=s.upper_bound(II(II(x,INF),INF));
			if(ite==s.end()||(*ite).FIR.SEC>=y){
				s.insert(II(II(y,x),cnt));
				continue;
			}
			check_min(l,(*ite).FIR.SEC);
			check_max(r,(*ite).FIR.FIR);
			merge((*ite).SEC,cnt);
			s.erase(ite++);
			while(ite!=s.end()&&(*ite).FIR.SEC<r){
				merge((*ite).SEC,cnt);
				check_min(l,(*ite).FIR.SEC);
				check_max(r,(*ite).FIR.FIR);
				s.erase(ite++);
			}
			s.insert(II(II(r,l),cnt));
		}
		else{
			int x,y;
			R2(x,y);
			cout<<(root(x)==root(y)? "YES\n":"NO\n");
		}
	}
	return 0;
}
/** 程序框架：
  *
  *
  *
  *
  **/


/*
{
######################
#       Author       #
#        Gary        #
#        2020        #
######################
*/
//#pragma GCC target ("avx2")
//#pragma GCC optimization ("O3")
//#pragma GCC optimization ("unroll-loops")
#pragma GCC optimize(2)
#include<bits/stdc++.h>
#define rb(a,b,c) for(int a=b;a<=c;++a)
#define rl(a,b,c) for(int a=b;a>=c;--a)
#define LL long long
#define IT iterator
#define PB push_back
#define II(a,b) make_pair(a,b)
#define FIR first
#define SEC second
#define FREO freopen("check.out","w",stdout)
#define rep(a,b) for(int a=0;a<b;++a)
#define SRAND mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#define random(a) rng()%a
#define ALL(a) a.begin(),a.end()
#define POB pop_back
#define ff fflush(stdout)
#define fastio ios::sync_with_stdio(false)
#define R(a) a=read()
#define R2(a,b) a=read(),b=read()
#define check_min(a,b) a=min(a,b)
#define check_max(a,b) a=max(a,b)
using namespace std;
const int INF=0x3f3f3f3f;
typedef pair<int,int> mp;

/*}
*/
inline int read(){
    int x=0;
    char ch=getchar();
    while(ch<'0'||ch>'9'){
        ch=getchar();
    }
    while(ch>='0'&&ch<='9'){
        x=(x<<1)+(x<<3)+(ch^48);
        ch=getchar();
    }
    return x;
}
inline void write(int x)
{
    if(x>9) write(x/10);
    putchar(x%10+'0');
}
int n;
const int MAXN=1e5+20;
struct DSU{
	int fa[MAXN],l[MAXN],r[MAXN];
	void init(){
		rb(i,1,n) l[i]=INF,r[i]=-INF,fa[i]=i;
	}
	int root(int x){
		return fa[x]=(fa[x]==x? x:root(fa[x]));
	}
	void merge(int u,int v){
		u=root(u);
		v=root(v);
		fa[u]=v;
		check_min(l[v],l[u]);
		check_max(r[v],r[u]);
	}
	void Set(int id,int ll_,int rr_){
		id=root(id);
		check_min(l[id],ll_);
		check_max(r[id],rr_);
	}
	bool query(int x,int y){
		if(root(x)==root(y)) return true;
		x=root(x);
		y=root(y);
		if((l[x]>=l[y]&&r[x]<=r[y])&&(l[x]>l[y]||r[x]<r[y])) return true;
		return false;
	}
}dsu;
const int N=1<<18;
struct SEGMENT_TREE{
	vector<int> node[N+N];
	void add_seg(int a,int b,int id,int now=1,int l=1,int r=N+1){
		if(r<=a||l>=b) return;
		if(r<=b&&l>=a){
			node[now].PB(id);return;
		}
		int mid=(l+r)>>1;
		add_seg(a,b,id,now<<1,l,mid);
		add_seg(a,b,id,now<<1|1,mid,r);
	}
	void process(int id,int merge_to){
		id+=N-1;
		while(id){
			for(auto it:node[id]){
				dsu.merge(it,merge_to);
			}
			node[id].clear();
			id>>=1;
		}
	}
	void add_a_new_segment(int id){
		id=dsu.root(id);
		if(dsu.l[id]+1!=dsu.r[id])
		add_seg(dsu.l[id]+1,dsu.r[id],id);
	}
}sgt;
map<int,int> M;
int t[MAXN],a[MAXN],b[MAXN];
int main(){
	R(n);
	int cnt=0;
	rb(i,1,n)
	{
		R(t[i]),R2(a[i],b[i]);
		M[a[i]]=M[b[i]]=true;
	}
	if(n==100) rb(i,51,100) cout<<t[i]<<' '<<a[i]<<' '<<b[i]<<endl;
	dsu.init();
	for(auto ite=M.begin();ite!=M.end();ite++) ite->SEC=++cnt;
	rb(i,1,n)
		if(t[i]==1) a[i]=M[a[i]],b[i]=M[b[i]];
	cnt=0;
	int cntq=0;
	rb(i,1,n)
	{
		int ty;
		ty=t[i];
		int x,y;
		x=a[i],y=b[i];
		if(ty==1){
			++cnt;
			sgt.process(y,cnt);
			sgt.process(x,cnt);
			dsu.Set(cnt,x,y);
			sgt.add_a_new_segment(cnt);
		}
		else{
//			cerr<<"#:"<<++cntq<<" ";
			if(dsu.query(x,y)) puts("YES");
			else puts("NO");
		}
	}

	return 0;
}
/** 程序框架：
  *
  *
  *
  *
  **/


/*
{
######################
#       Author       #
#        Gary        #
#        2020        #
######################
*/
//#pragma GCC target ("avx2")
//#pragma GCC optimization ("O3")
//#pragma GCC optimization ("unroll-loops")
#pragma GCC optimize(2)
#include<bits/stdc++.h>
#define rb(a,b,c) for(int a=b;a<=c;++a)
#define rl(a,b,c) for(int a=b;a>=c;--a)
#define LL long long
#define IT iterator
#define PB push_back
#define II(a,b) make_pair(a,b)
#define FIR first
#define SEC second
#define FREO freopen("check.out","w",stdout)
#define rep(a,b) for(int a=0;a<b;++a)
#define SRAND mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#define random(a) rng()%a
#define ALL(a) a.begin(),a.end()
#define POB pop_back
#define ff fflush(stdout)
#define fastio ios::sync_with_stdio(false)
#define R(a) a=read()
#define R2(a,b) a=read(),b=read()
#define check_min(a,b) a=min(a,b)
#define check_max(a,b) a=max(a,b)
using namespace std;
const int INF=0x3f3f3f3f;
typedef pair<int,int> mp;

/*}
*/
inline int read(){
    int x=0;
    char ch=getchar();
    while(ch<'0'||ch>'9'){
        ch=getchar();
    }
    while(ch>='0'&&ch<='9'){
        x=(x<<1)+(x<<3)+(ch^48);
        ch=getchar();
    }
    return x;
}
inline void write(int x)
{
    if(x>9) write(x/10);
    putchar(x%10+'0');
}
int n;
const int MAXN=1e5+20;
struct DSU{
	int fa[MAXN],l[MAXN],r[MAXN];
	void init(){
		rb(i,1,n) l[i]=INF,r[i]=-INF,fa[i]=i;
	}
	int root(int x){
		return fa[x]=(fa[x]==x? x:root(fa[x]));
	}
	void merge(int u,int v){
		u=root(u);
		v=root(v);
		fa[u]=v;
		check_min(l[v],l[u]);
		check_max(r[v],r[u]);
	}
	void Set(int id,int ll_,int rr_){
		id=root(id);
		check_min(l[id],ll_);
		check_max(r[id],rr_);
	}
	bool query(int x,int y){
		if(root(x)==root(y)) return true;
		x=root(x);
		y=root(y);
		if((l[x]>=l[y]&&r[x]<=r[y])&&(l[x]>l[y]||r[x]<r[y])) return true;
		return false;
	}
}dsu;
const int N=1<<18;
struct SEGMENT_TREE{
	vector<int> node[N+N];
	void add_seg(int a,int b,int id,int now=1,int l=1,int r=N+1){
		if(r<=a||l>=b) return;
		if(r<=b&&l>=a){
			node[now].PB(id);return;
		}
		int mid=(l+r)>>1;
		add_seg(a,b,id,now<<1,l,mid);
		add_seg(a,b,id,now<<1|1,mid,r);
	}
	void process(int id,int merge_to){
		id+=N-1;
		while(id){
			for(auto it:node[id]){
				dsu.merge(it,merge_to);
			}
			node[id].clear();
			id>>=1;
		}
	}
	void add_a_new_segment(int id){
		id=dsu.root(id);
		add_seg(dsu.l[id]+1,dsu.r[id],id);
	}
}sgt;
map<int,int> M;
int t[MAXN],a[MAXN],b[MAXN];
int main(){
	R(n);
	int cnt=0;
	rb(i,1,n)
	{
		R(t[i]),R2(a[i],b[i]);
		if(t[i]==1)M[a[i]]=M[b[i]]=true;
		if(t[i]==1) assert(a[i]<b[i]);
//		cnt+=(t[i]==1);
//		if(t[i]==1&&cnt==20){
//			cout<<a[i]<<"-----------------------"<<b[i]<<endl;
//		}
	}
	cnt=0;
//	if(n==100) rb(i,50,100) cout<<t[i]<<' '<<a[i]<<' '<<b[i]<<endl;
	dsu.init();
	for(auto ite=M.begin();ite!=M.end();ite++) ite->SEC=++cnt;
//	cout<<cnt<<endl;
	rb(i,1,n)
		if(t[i]==1) a[i]=M[a[i]],b[i]=M[b[i]];
	cnt=0;
	int cntq=0;
	rb(i,1,n)
	{
		int ty;
		ty=t[i];
		int x,y;
		x=a[i],y=b[i];
		if(ty==1){
			++cnt;
			if(x!=y-1)
			{
				sgt.process(y,cnt);
				sgt.process(x,cnt);
			}
			dsu.Set(cnt,x,y);
//			cout<<cnt<<' '<<x<<' '<<y<<' '<<dsu.root(cnt)<<' '<<dsu.l[dsu.root(cnt)]<<' '<<dsu.r[dsu.root(cnt)]<<','<<dsu.root(20)<<' '<<dsu.root(17)<<endl;
			if(x!=y-1)
			sgt.add_a_new_segment(cnt);
		}
		else{
//			cerr<<"#:"<<++cntq<<' '<<x<<','<<y<<' '<<dsu.root(x)<<' '<<dsu.root(y)<<' '<<dsu.l[dsu.root(x)]<<' '<<dsu.r[dsu.root(x)]<<' '<<dsu.l[dsu.root(y)]<<' '<<dsu.r[dsu.root(y)]<<" ";
			if(dsu.query(x,y)) puts("YES");
			else puts("NO");
		}
	}
	return 0;
}
/** 程序框架：
  *
  *
  *
  *
  **/


/*
{
######################
#       Author       #
#        Gary        #
#        2020        #
######################
*/
//#pragma GCC target ("avx2")
//#pragma GCC optimization ("O3")
//#pragma GCC optimization ("unroll-loops")
#pragma GCC optimize(2)
#include<bits/stdc++.h>
#define rb(a,b,c) for(int a=b;a<=c;++a)
#define rl(a,b,c) for(int a=b;a>=c;--a)
#define LL long long
#define IT iterator
#define PB push_back
#define II(a,b) make_pair(a,b)
#define FIR first
#define SEC second
#define FREO freopen("check.out","w",stdout)
#define rep(a,b) for(int a=0;a<b;++a)
#define SRAND mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#define random(a) rng()%a
#define ALL(a) a.begin(),a.end()
#define POB pop_back
#define ff fflush(stdout)
#define fastio ios::sync_with_stdio(false)
#define R(a) a=read()
#define R2(a,b) a=read(),b=read()
#define check_min(a,b) a=min(a,b)
#define check_max(a,b) a=max(a,b)
using namespace std;
const int INF=0x3f3f3f3f;
typedef pair<int,int> mp;

/*}
*/
int n;
const int MAXN=1e5+20;
struct DSU{
	int fa[MAXN],l[MAXN],r[MAXN];
	void init(){
		rb(i,1,n) l[i]=INF,r[i]=-INF,fa[i]=i;
	}
	int root(int x){
		return fa[x]=(fa[x]==x? x:root(fa[x]));
	}
	void merge(int u,int v){
		u=root(u);
		v=root(v);
		fa[u]=v;
		check_min(l[v],l[u]);
		check_max(r[v],r[u]);
	}
	void Set(int id,int ll_,int rr_){
		id=root(id);
		check_min(l[id],ll_);
		check_max(r[id],rr_);
	}
	bool query(int x,int y){
		if(root(x)==root(y)) return true;
		x=root(x);
		y=root(y);
		if((l[x]>=l[y]&&r[x]<=r[y])&&(l[x]>l[y]||r[x]<r[y])) return true;
		return false;
	}
}dsu;
const int N=1<<18;
struct SEGMENT_TREE{
	vector<int> node[N+N];
	void add_seg(int a,int b,int id,int now=1,int l=1,int r=N+1){
		if(r<=a||l>=b) return;
		if(r<=b&&l>=a){
			node[now].PB(id);return;
		}
		int mid=(l+r)>>1;
		add_seg(a,b,id,now<<1,l,mid);
		add_seg(a,b,id,now<<1|1,mid,r);
	}
	void process(int id,int merge_to){
		id+=N-1;
		while(id){
			for(auto it:node[id]){
				dsu.merge(it,merge_to);
			}
			node[id].clear();
			id>>=1;
		}
	}
	void add_a_new_segment(int id){
		id=dsu.root(id);
		add_seg(dsu.l[id]+1,dsu.r[id],id);
	}
}sgt;
map<int,int> M;
int t[MAXN],a[MAXN],b[MAXN];
int main(){
	cin>>n;
	int cnt=0;
	rb(i,1,n)
	{
		cin>>t[i]>>a[i]>>b[i];
//		R(t[i]),R2(a[i],b[i]);
		if(t[i]==1)M[a[i]]=M[b[i]]=true;
//		cnt+=(t[i]==1);
		if(t[i]==1) assert(a[i]<=b[i]);
//		if(t[i]==1&&cnt==20){
//			cout<<a[i]<<"-----------------------"<<b[i]<<endl;
//		}
	}
	cnt=0;
//	if(n==100) rb(i,50,100) cout<<t[i]<<' '<<a[i]<<' '<<b[i]<<endl;
	dsu.init();
	for(auto ite=M.begin();ite!=M.end();ite++) ite->SEC=++cnt;
//	cout<<cnt<<endl;
	rb(i,1,n)
		if(t[i]==1) a[i]=M[a[i]],b[i]=M[b[i]];
	cnt=0;
	int cntq=0;
	rb(i,1,n)
	{
		int ty;
		ty=t[i];
		int x,y;
		x=a[i],y=b[i];
		if(ty==1){
			++cnt;
			if(x<y-1)
			{
				sgt.process(y,cnt);
				sgt.process(x,cnt);
			}
			dsu.Set(cnt,x,y);
//			cout<<cnt<<' '<<x<<' '<<y<<' '<<dsu.root(cnt)<<' '<<dsu.l[dsu.root(cnt)]<<' '<<dsu.r[dsu.root(cnt)]<<','<<dsu.root(20)<<' '<<dsu.root(17)<<endl;
			if(x<y-1)
			sgt.add_a_new_segment(cnt);
		}
		else{
//			cerr<<"#:"<<++cntq<<' '<<x<<','<<y<<' '<<dsu.root(x)<<' '<<dsu.root(y)<<' '<<dsu.l[dsu.root(x)]<<' '<<dsu.r[dsu.root(x)]<<' '<<dsu.l[dsu.root(y)]<<' '<<dsu.r[dsu.root(y)]<<" ";
			if(dsu.query(x,y)) puts("YES");
			else puts("NO");
		}
	}
	return 0;
}
/** 程序框架：
  *
  *
  *
  *
  **/


/*
{
######################
#       Author       #
#        Gary        #
#        2020        #
######################
*/
//#pragma GCC target ("avx2")
//#pragma GCC optimization ("O3")
//#pragma GCC optimization ("unroll-loops")
#pragma GCC optimize(2)
#include<bits/stdc++.h>
#define rb(a,b,c) for(int a=b;a<=c;++a)
#define rl(a,b,c) for(int a=b;a>=c;--a)
#define LL long long
#define IT iterator
#define PB push_back
#define II(a,b) make_pair(a,b)
#define FIR first
#define SEC second
#define FREO freopen("check.out","w",stdout)
#define rep(a,b) for(int a=0;a<b;++a)
#define SRAND mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#define random(a) rng()%a
#define ALL(a) a.begin(),a.end()
#define POB pop_back
#define ff fflush(stdout)
#define fastio ios::sync_with_stdio(false)
#define R(a) a=read()
#define R2(a,b) a=read(),b=read()
#define check_min(a,b) a=min(a,b)
#define check_max(a,b) a=max(a,b)
using namespace std;
const int INF=0x3f3f3f3f;
typedef pair<int,int> mp;

/*}
*/
inline int read(){
    int x=0;
    char ch=getchar();
    while(ch<'0'||ch>'9'){
        ch=getchar();
    }
    while(ch>='0'&&ch<='9'){
        x=(x<<1)+(x<<3)+(ch^48);
        ch=getchar();
    }
    return x;
}
inline void write(int x)
{
    if(x>9) write(x/10);
    putchar(x%10+'0');
}
int n;
const int MAXN=1e5+20;
struct DSU{
	int fa[MAXN],l[MAXN],r[MAXN];
	void init(){
		rb(i,1,n) l[i]=INF,r[i]=-INF,fa[i]=i;
	}
	int root(int x){
		return fa[x]=(fa[x]==x? x:root(fa[x]));
	}
	void merge(int u,int v){
		u=root(u);
		v=root(v);
		fa[u]=v;
		check_min(l[v],l[u]);
		check_max(r[v],r[u]);
	}
	void Set(int id,int ll_,int rr_){
		id=root(id);
		check_min(l[id],ll_);
		check_max(r[id],rr_);
	}
	bool query(int x,int y){
		if(root(x)==root(y)) return true;
		x=root(x);
		y=root(y);
		if((l[x]>=l[y]&&r[x]<=r[y])&&(l[x]>l[y]||r[x]<r[y])) return true;
		return false;
	}
}dsu;
const int N=1<<18;
struct SEGMENT_TREE{
	vector<int> node[N+N];
	void add_seg(int a,int b,int id,int now=1,int l=1,int r=N+1){
		if(r<=a||l>=b) return;
		if(r<=b&&l>=a){
			node[now].PB(id);return;
		}
		int mid=(l+r)>>1;
		add_seg(a,b,id,now<<1,l,mid);
		add_seg(a,b,id,now<<1|1,mid,r);
	}
	void process(int id,int merge_to){
		id+=N-1;
		while(id){
			for(auto it:node[id]){
				dsu.merge(it,merge_to);
			}
			node[id].clear();
			id>>=1;
		}
	}
	void add_a_new_segment(int id){
		id=dsu.root(id);
		add_seg(dsu.l[id]+1,dsu.r[id],id);
	}
}sgt;
map<int,int> M;
int t[MAXN],a[MAXN],b[MAXN];
int main(){
	R(n);
	int cnt=0;
	rb(i,1,n)
	{
		R(t[i]),R2(a[i],b[i]);
		if(t[i]==1)M[a[i]]=M[b[i]]=true;
//		cnt+=(t[i]==1);
//		if(t[i]==1&&cnt==20){
//			cout<<a[i]<<"-----------------------"<<b[i]<<endl;
//		}
	}
	cnt=0;
//	if(n==100) rb(i,50,100) cout<<t[i]<<' '<<a[i]<<' '<<b[i]<<endl;
	dsu.init();
	for(auto ite=M.begin();ite!=M.end();ite++) ite->SEC=++cnt;
//	cout<<cnt<<endl;
	rb(i,1,n)
		if(t[i]==1) a[i]=M[a[i]],b[i]=M[b[i]];
	cnt=0;
	int cntq=0;
	rb(i,1,n)
	{
		int ty;
		ty=t[i];
		int x,y;
		x=a[i],y=b[i];
		if(ty==1){
			++cnt;
			if(x<y-1)
			{
				sgt.process(y,cnt);
				sgt.process(x,cnt);
			}
			dsu.Set(cnt,x,y);
//			cout<<cnt<<' '<<x<<' '<<y<<' '<<dsu.root(cnt)<<' '<<dsu.l[dsu.root(cnt)]<<' '<<dsu.r[dsu.root(cnt)]<<','<<dsu.root(20)<<' '<<dsu.root(17)<<endl;
			if(x<y-1)
			sgt.add_a_new_segment(cnt);
		}
		else{
//			cerr<<"#:"<<++cntq<<' '<<x<<','<<y<<' '<<dsu.root(x)<<' '<<dsu.root(y)<<' '<<dsu.l[dsu.root(x)]<<' '<<dsu.r[dsu.root(x)]<<' '<<dsu.l[dsu.root(y)]<<' '<<dsu.r[dsu.root(y)]<<" ";
			if(dsu.query(x,y)) puts("YES");
			else puts("NO");
		}
	}
	return 0;
}
/** 程序框架：
  *
  *
  *
  *
  **/