#include <bits/stdc++.h>
using namespace std;
const int maxn = 200000 + 10;
int n, k, m;
multiset<int> s;
set<pair<long long, int> > v[maxn];
struct node {
  int num;
  int x;
  long long T;
  bool operator<(const node& x) const { return T > x.T; }
};
priority_queue<node> p;
void POP(long long T) {
  while (!p.empty()) {
    node tmp = p.top();
    if (tmp.T > T) break;
    p.pop();
    s.insert(tmp.x);
    v[tmp.x].insert({tmp.T, tmp.num});
  }
}
int main() {
  scanf("%d%d%d", &n, &k, &m);
  for (int i = 1; i <= k; i++) {
    int loc;
    scanf("%d", &loc);
    p.push({i, loc, 0});
  }
  int a, b;
  long long T;
  for (int i = 1; i <= m; i++) {
    scanf("%I64d%d%d", &T, &a, &b);
    POP(T);
    if (s.empty()) POP((p.top()).T);
    auto it = s.lower_bound(a);
    int dis = INT_MAX;
    int x;
    pair<long long, int> contain;
    if (it != s.end()) {
      x = *it;
      dis = abs(*it - a);
      contain = *v[x].begin();
    }
    if (it != s.begin()) {
      it--;
      int x2 = *it;
      if (abs(x2 - a) < dis)
        dis = abs(x2 - a), contain = *v[x2].begin(), x = x2;
      else if (abs(x2 - a) == dis and *v[x2].begin() < contain)
        contain = *v[x2].begin(), x = x2;
    }
    printf("%d %I64d\n", contain.second, dis + max(T, contain.first) - T);
    s.erase(s.find(x));
    v[x].erase(v[x].begin());
    p.push({contain.second, b, dis + max(T, contain.first) + abs(b - a)});
  }
  return 0;
}
