#include <bits/stdc++.h>
#pragma warning(disable : 4996)
#pragma comment(linker, "/STACK:336777216")
using namespace std;
int IT_MAX = 1 << 18;
const long long MOD = 1000000007;
const int INF = 0x3f3f3f3f;
const long long LL_INF = 0x1f3f3f3f3f3f3f3f;
const double PI = acos(-1);
const double ERR = 1e-12;
long long X[200050];
long long val[200050];
pair<long long, long long> indt[600050];
set<pair<long long, long long>> Sx[600050];
void update(int p, int v, int o, long long curt) {
  p += IT_MAX - 1;
  if (o == 1) {
    X[v] = p - IT_MAX + 1;
    val[v] = curt;
    Sx[p].emplace(curt, v);
    for (; p; p /= 2)
      indt[p] = min(indt[p], pair<long long, long long>(curt, v));
  } else {
    pair<long long, long long> u = pair<long long, long long>(val[v], v);
    Sx[p].erase(u);
    indt[p] = pair<long long, long long>(LL_INF, LL_INF);
    if (!Sx[p].empty()) indt[p] = *Sx[p].begin();
    for (p /= 2; p; p /= 2) indt[p] = min(indt[2 * p], indt[2 * p + 1]);
  }
}
pair<int, pair<long long, long long>> getlower(int n) {
  int p = IT_MAX + n - 1;
  while (1) {
    if (indt[p] != pair<long long, long long>(LL_INF, LL_INF)) break;
    if (p & (p - 1))
      ;
    else
      return make_pair(-INF, pair<long long, long long>(LL_INF, LL_INF));
    p = (p - 1) / 2;
  }
  while (p < IT_MAX) {
    if (indt[2 * p + 1] != pair<long long, long long>(LL_INF, LL_INF))
      p = 2 * p + 1;
    else
      p = 2 * p;
  }
  return make_pair(p - IT_MAX + 1, indt[p]);
}
pair<int, pair<long long, long long>> getupper(int n) {
  int p = IT_MAX + n - 1;
  while (1) {
    if (indt[p] != pair<long long, long long>(LL_INF, LL_INF)) break;
    if (p & (p + 1))
      ;
    else
      return make_pair(INF, pair<long long, long long>(LL_INF, LL_INF));
    p = (p + 1) / 2;
  }
  while (p < IT_MAX) {
    if (indt[2 * p] != pair<long long, long long>(LL_INF, LL_INF))
      p = 2 * p;
    else
      p = 2 * p + 1;
  }
  return make_pair(p - IT_MAX + 1, indt[p]);
}
priority_queue<pair<long long, pair<long long, long long>>,
               vector<pair<long long, pair<long long, long long>>>,
               greater<pair<long long, pair<long long, long long>>>>
    Hx1;
priority_queue<int, vector<int>, greater<int>> Hx2;
long long in[200050][3];
int main() {
  int N, K, M, i, j;
  scanf("%d %d %d", &N, &K, &M);
  for (i = 1; i <= K; i++) scanf("%lld", &X[i]);
  for (i = 1; i <= M; i++) {
    scanf("%lld %lld %lld", &in[i][0], &in[i][1], &in[i][2]);
    Hx1.emplace(in[i][0], pair<long long, long long>(i, i));
  }
  for (i = 1; i < 2 * IT_MAX; i++)
    indt[i] = pair<long long, long long>(LL_INF, LL_INF);
  for (i = 1; i <= K; i++) update(X[i], i, 1, 0);
  long long curt = 0;
  while (!Hx1.empty() || !Hx2.empty()) {
    curt = Hx1.top().first;
    while (!Hx1.empty()) {
      if (Hx1.top().first != curt) break;
      pair<long long, long long> t = Hx1.top().second;
      Hx1.pop();
      if (t.first > 0)
        Hx2.push(t.first);
      else
        update(t.second, -t.first, 1, curt);
    }
    while (!Hx2.empty()) {
      int t = Hx2.top();
      auto u1 = getlower(in[t][1]);
      auto u2 = getupper(in[t][1]);
      u1.first = in[t][1] - u1.first;
      u2.first = u2.first - in[t][1];
      if (u1 > u2) u1 = u2;
      if (u1.second.second >= 1 && u1.second.second <= K) {
        printf("%lld %lld\n", u1.second.second, curt - in[t][0] + u1.first);
        update(X[u1.second.second], u1.second.second, -1, curt);
        Hx1.emplace(curt + u1.first + abs(in[t][1] - in[t][2]),
                    pair<long long, long long>(-u1.second.second, in[t][2]));
        Hx2.pop();
      } else
        break;
    }
  }
  return 0;
}
