#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 5;
int bit[N];
set<pair<long long, int>> s[N];
int find(int i) {
  int ret = 0;
  for (; i >= 0; i = (i & (i + 1)) - 1) ret += bit[i];
  return ret;
}
int find(int l, int r) { return find(r) - find(l - 1); }
void add(int i, int v) {
  for (; i < N; i |= i + 1) bit[i] += v;
}
void remove_taxi(int at, pair<long long, int> v) {
  add(at, -1);
  s[at].erase(v);
}
void add_taxi(int at, pair<long long, int> v) {
  add(at, 1);
  s[at].insert(v);
}
pair<long long, int> get_taxi(int at) {
  auto it = *(s[at].begin());
  return it;
}
int main() {
  priority_queue<tuple<long long, int, int>> pq;
  int n, k, m;
  scanf("%d %d %d", &n, &k, &m);
  for (int i = 1; i <= k; i++) {
    int x;
    scanf("%d", &x);
    add_taxi(x, {0, i});
  }
  long long now = 0;
  vector<tuple<long long, int, int>> qq;
  while (m--) {
    long long t;
    int a, b;
    scanf("%lld %d %d", &t, &a, &b);
    qq.emplace_back(t, a, b);
  }
  for (auto it : qq) {
    long long t;
    int a, b;
    tie(t, a, b) = it;
    while (!pq.empty() && -get<0>(pq.top()) <= t) {
      long long time;
      int at, id;
      tie(time, at, id) = pq.top();
      time = -time;
      pq.pop();
      add_taxi(at, {time, id});
    }
    now = max(now, t);
    if (find(1, n) == 0) {
      long long time;
      int at, id;
      tie(time, at, id) = pq.top();
      time = -time;
      pq.pop();
      add_taxi(at, {time, id});
      now = max(now, time);
      while (!pq.empty() && -get<0>(pq.top()) <= now) {
        tie(time, at, id) = pq.top();
        time = -time;
        pq.pop();
        add_taxi(at, {time, id});
      }
    }
    tuple<int, long long, int, int> cur = make_tuple(N, N, N, N);
    int l = 1, r = a;
    while (l < r) {
      int mid = (l + r + 1) >> 1;
      if (find(mid, a)) {
        l = mid;
      } else {
        r = mid - 1;
      }
    }
    if (find(l, a)) {
      auto it = get_taxi(l);
      cur = min(cur, make_tuple(a - l, it.first, it.second, l));
    }
    l = a, r = n;
    while (l < r) {
      int mid = (l + r) >> 1;
      if (find(a, mid)) {
        r = mid;
      } else {
        l = mid + 1;
      }
    }
    if (find(a, l)) {
      auto it = get_taxi(l);
      cur = min(cur, make_tuple(l - a, it.first, it.second, l));
    }
    int d, id, at;
    long long time;
    tie(d, time, id, at) = cur;
    remove_taxi(at, {time, id});
    pq.emplace(-(now + d + abs(b - a)), b, id);
    printf("%d %lld\n", id, now + d - t);
  }
  return 0;
}
