#include <bits/stdc++.h>
using namespace std;
template <typename T1, typename T2>
bool Max(T1 &a, T2 b) {
  return a < b ? a = b, 1 : 0;
}
template <typename T1, typename T2>
bool Min(T1 &a, T2 b) {
  return a > b ? a = b, 1 : 0;
}
template <int MOD>
struct ModInt {
  unsigned x;
  ModInt() : x(0) {}
  ModInt(signed sig) : x(sig) {}
  ModInt(signed long long sig) : x(sig % MOD) {}
  int get() const { return (int)x; }
  ModInt pow(long long p) {
    ModInt res = 1, a = *this;
    while (p) {
      if (p & 1) res *= a;
      a *= a;
      p >>= 1;
    }
    return res;
  }
  ModInt &operator+=(ModInt that) {
    if ((x += that.x) >= MOD) x -= MOD;
    return *this;
  }
  ModInt &operator-=(ModInt that) {
    if ((x += MOD - that.x) >= MOD) x -= MOD;
    return *this;
  }
  ModInt &operator*=(ModInt that) {
    x = (unsigned long long)x * that.x % MOD;
    return *this;
  }
  ModInt &operator/=(ModInt that) { return (*this) *= that.pow(MOD - 2); }
  ModInt operator+(ModInt that) const { return ModInt(*this) += that; }
  ModInt operator-(ModInt that) const { return ModInt(*this) -= that; }
  ModInt operator*(ModInt that) const { return ModInt(*this) *= that; }
  ModInt operator/(ModInt that) const { return ModInt(*this) /= that; }
  bool operator<(ModInt that) const { return x < that.x; }
  friend ostream &operator<<(ostream &os, ModInt a) {
    os << a.x;
    return os;
  }
};
template <class T>
T gcd(T a, T b) {
  return b ? gcd(b, a % b) : a;
}
const int N = 300003, inf = 1e9;
map<int, queue<pair<long long, long long>>> avail;
priority_queue<pair<pair<long long, long long>, int>,
               vector<pair<pair<long long, long long>, int>>,
               greater<pair<pair<long long, long long>, int>>>
    q;
void solve() {
  int n, k, m, x, y;
  long long t;
  cin >> k >> n >> m;
  avail[-k * 10].push({0, 0});
  avail[k * 10].push({0, 0});
  for (int i = 1; i <= (n); ++i) {
    cin >> x;
    avail[x].emplace(0, i);
  }
  long long now = 0;
  while (m--) {
    cin >> t >> x >> y;
    Max(now, t);
    if (avail.size() == 2) {
      Max(now, q.top().first.first);
    }
    while (q.size()) {
      auto cur = q.top();
      if (cur.first.first > now) break;
      q.pop();
      avail[cur.second].push(cur.first);
    }
    auto it = avail.lower_bound(x);
    auto it2 = it;
    it2--;
    int dif1 = it->first - x;
    int dif2 = x - it2->first;
    auto t1 = it->second.front();
    auto t2 = it2->second.front();
    long long car;
    int dis = min(dif1, dif2);
    if (dif1 < dif2 || dif1 == dif2 && t1 < t2) {
      car = t1.second;
      it->second.pop();
      if (it->second.empty()) avail.erase(it);
    } else {
      car = t2.second;
      it2->second.pop();
      if (it2->second.empty()) avail.erase(it2);
    }
    cout << car << ' ' << (now + dis - t) << '\n';
    q.emplace(pair<long long, long long>{now + dis + abs(y - x), car}, y);
  }
}
void init() {}
int main(void) {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.setf(ios::fixed);
  cout.precision(20);
  init();
  int TC = 1;
  for (int TI = 1; TI <= (TC); ++TI) {
    solve();
  }
  return 0;
}
