#include <bits/stdc++.h>
#pragma warning(disable : 4996)
template <typename T>
T min(T x, T y) {
  return x < y ? x : y;
}
template <typename T>
T max(T x, T y) {
  return x > y ? x : y;
};
long long mabs(long long x) { return x >= 0 ? x : -x; }
const long long INF = 2000000005;
struct car {
  long long id;
  long long pos;
  long long tim;
  car(long long I = 0, long long P = 0, long long T = 0) {
    id = I;
    pos = P;
    tim = T;
  }
};
struct tree {
  car data;
  long long size;
  tree *lson;
  tree *rson;
  tree(car D = car()) {
    data = D;
    size = 1;
    lson = rson = NULL;
  }
  void fixup() { size = (lson ? lson->size : 0) + (rson ? rson->size : 0) + 1; }
};
struct pair {
  tree *fir;
  tree *sec;
  pair(tree *F = NULL, tree *S = NULL) {
    fir = F;
    sec = S;
  }
};
bool shouldleft(long long a, long long b) {
  return (rand() * 10000 + rand() % 10000) % (a + b) < a;
}
tree *merge(tree *T1, tree *T2) {
  if (!T1) return T2;
  if (!T2) return T1;
  if (shouldleft(T1->size, T2->size)) {
    T1->rson = merge(T1->rson, T2);
    T1->fixup();
    return T1;
  }
  T2->lson = merge(T1, T2->lson);
  T2->fixup();
  return T2;
}
pair split(tree *T, long long k) {
  if (!T) return pair();
  long long r = (T->lson ? T->lson->size : 0) + 1;
  pair t;
  if (r <= k) {
    t = split(T->rson, k - r);
    T->rson = t.fir;
    T->fixup();
    return pair(T, t.sec);
  }
  t = split(T->lson, k);
  T->lson = t.sec;
  T->fixup();
  return pair(t.fir, T);
}
long long rank(tree *T, car d, bool (*cmp)(car, car)) {
  if (!T) return 0;
  long long r = (T->lson ? T->lson->size : 0) + 1;
  if (cmp(T->data, d)) return r + rank(T->rson, d, cmp);
  return rank(T->lson, d, cmp);
}
void insert(tree *&T, car d, bool (*cmp)(car, car)) {
  long long r = rank(T, d, cmp);
  pair t = split(T, r);
  T = merge(t.fir, merge(new tree(d), t.sec));
}
void del(tree *&T, car d, bool (*cmp)(car, car)) {
  long long r = rank(T, d, cmp);
  pair t = split(T, r);
  pair t2 = split(t.fir, r - 1);
  delete t2.sec;
  T = merge(t2.fir, t.sec);
}
tree *minimum(tree *T) {
  while (T->lson) T = T->lson;
  return T;
}
tree *maximum(tree *T) {
  while (T->rson) T = T->rson;
  return T;
}
bool cmp1(car a, car b) {
  if (a.pos != b.pos) return a.pos < b.pos;
  if (a.tim != b.tim) return a.tim < b.tim;
  return a.id <= b.id;
}
bool cmp2(car a, car b) {
  if (a.tim != b.tim) return a.tim < b.tim;
  if (a.pos != b.pos) return a.pos < b.pos;
  return a.id <= b.id;
}
long long N, K, M;
tree *T1, *T2;
long long cur;
void init() {
  long long t;
  scanf("%I64d %I64d %I64d", &N, &K, &M);
  for (long long i = 1; i <= K; i++) {
    scanf("%I64d", &t);
    insert(T1, car(i, t, 0), cmp1);
  }
}
car get_nearest(long long t, long long x) {
  cur = max(cur, t);
  while (T2 && minimum(T2)->data.tim <= cur) {
    pair pa = split(T2, 1);
    insert(T1, pa.fir->data, cmp1);
    delete pa.fir;
    T2 = pa.sec;
  }
  long long tmp;
  car car1, car2;
  if (!T1) {
    cur = minimum(T2)->data.tim;
    while (T2 && minimum(T2)->data.tim <= cur) {
      pair pa = split(T2, 1);
      insert(T1, pa.fir->data, cmp1);
      delete pa.fir;
      T2 = pa.sec;
    }
  }
  tmp = rank(T1, car(-1, x, -1), cmp1);
  pair pir = split(T1, tmp);
  car2 = (pir.sec ? minimum(pir.sec)->data : car(0, INF, 0));
  long long low = pir.fir ? maximum(pir.fir)->data.pos : -1;
  T1 = merge(pir.fir, pir.sec);
  if (low == -1)
    car1 = car(0, INF, 0);
  else {
    tmp = rank(T1, car(-1, low, -1), cmp1);
    pair pir = split(T1, tmp);
    car1 = (pir.sec ? minimum(pir.sec)->data : car(0, INF, 0));
    T1 = merge(pir.fir, pir.sec);
  }
  if (mabs(car1.pos - x) < mabs(car2.pos - x) ||
      (mabs(car1.pos - x) == mabs(car2.pos - x) &&
       (car1.tim < car2.tim || (car1.tim == car2.tim && car1.id < car2.id)))) {
    del(T1, car1, cmp1);
    return car1;
  }
  del(T1, car2, cmp1);
  return car2;
}
void solve() {
  long long t, a, b;
  for (long long i = 1; i <= M; i++) {
    scanf("%I64d %I64d %I64d", &t, &a, &b);
    car c = get_nearest(t, a);
    long long wait = cur - t + mabs(c.pos - a);
    insert(T2, car(c.id, b, cur + mabs(c.pos - a) + mabs(a - b)), cmp2);
    printf("%I64d %I64d\n", c.id, wait);
  }
}
int main() {
  init();
  solve();
  return 0;
}
