#include <bits/stdc++.h>
using namespace std;
const int maxn = 200100;
const long long M1 = 998244353;
const long long M2 = 1000000007;
const long long M3 = 1333333331;
const long long oo = 1e16;
long long seed = maxn;
struct Tnode {
  long long stime;
  int val, id, fix;
  Tnode *lson, *rson;
} tree[maxn << 2];
Tnode *Root = NULL;
int cur = -1;
struct data {
  long long Time;
  int place, num;
} Heap[maxn];
int tail = 0;
int n, m, k;
int Rand() {
  seed = (seed * M1 + M2) % M3;
  return seed;
}
Tnode *New_node(int Val, long long Stime, int Id) {
  cur++;
  tree[cur].val = Val;
  tree[cur].stime = Stime;
  tree[cur].id = Id;
  tree[cur].fix = Rand();
  tree[cur].lson = tree[cur].rson = NULL;
  return tree + cur;
}
void Right_turn(Tnode *&P) {
  Tnode *W = P->lson;
  P->lson = W->rson;
  W->rson = P;
  P = W;
}
void Left_turn(Tnode *&P) {
  Tnode *W = P->rson;
  P->rson = W->lson;
  W->lson = P;
  P = W;
}
void Insert(Tnode *&P, int Val, long long Stime, int Id) {
  if (!P)
    P = New_node(Val, Stime, Id);
  else if (Val < P->val ||
           (Val == P->val &&
            (Stime < P->stime || (Stime == P->stime && Id < P->id)))) {
    Insert(P->lson, Val, Stime, Id);
    if (P->lson->fix < P->fix) Right_turn(P);
  } else {
    Insert(P->rson, Val, Stime, Id);
    if (P->rson->fix < P->fix) Left_turn(P);
  }
}
void Heap_Delete() {
  Heap[1] = Heap[tail];
  tail--;
  int x = 1;
  while (1) {
    int y = x, Left = x << 1, Right = Left | 1;
    if (Left <= tail && Heap[Left].Time < Heap[y].Time) y = Left;
    if (Right <= tail && Heap[Right].Time < Heap[y].Time) y = Right;
    if (x == y) break;
    swap(Heap[x], Heap[y]);
    x = y;
  }
}
void Work(long long t) {
  while (tail && Heap[1].Time <= t) {
    Insert(Root, Heap[1].place, Heap[1].Time, Heap[1].num);
    Heap_Delete();
  }
}
Tnode *Find_prev(Tnode *P, int Val, long long Stime, int Id, Tnode *ans) {
  if (!P) return ans;
  if (Val > P->val || (Val == P->val &&
                       (Stime > P->stime || (Stime == P->stime && Id > P->id))))
    return Find_prev(P->rson, Val, Stime, Id, P);
  return Find_prev(P->lson, Val, Stime, Id, ans);
}
Tnode *Find_succ(Tnode *P, int Val, long long Stime, int Id, Tnode *ans) {
  if (!P) return ans;
  if (Val < P->val || (Val == P->val &&
                       (Stime < P->stime || (Stime == P->stime && Id < P->id))))
    return Find_succ(P->lson, Val, Stime, Id, P);
  return Find_succ(P->rson, Val, Stime, Id, ans);
}
void Heap_Insert(long long t, int Place, int Num) {
  tail++;
  Heap[tail].Time = t;
  Heap[tail].place = Place;
  Heap[tail].num = Num;
  int x = tail;
  while (x > 1) {
    int y = x >> 1;
    if (Heap[y].Time < Heap[x].Time) break;
    swap(Heap[x], Heap[y]);
    x = y;
  }
}
void Delete(Tnode *&P, int Val, long long Stime, int Id) {
  if (Val == P->val && Stime == P->stime && Id == P->id)
    if (P->lson)
      if (P->rson)
        if (P->lson->fix < P->rson->fix) {
          Right_turn(P);
          Delete(P->rson, Val, Stime, Id);
        } else {
          Left_turn(P);
          Delete(P->lson, Val, Stime, Id);
        }
      else
        P = P->lson;
    else
      P = P->rson;
  else if (Val < P->val ||
           (Val == P->val &&
            (Stime < P->stime || (Stime == P->stime && Id < P->id))))
    Delete(P->lson, Val, Stime, Id);
  else
    Delete(P->rson, Val, Stime, Id);
}
int main() {
  scanf("%d%d%d", &n, &k, &m);
  for (int i = 1; i <= k; i++) {
    int x;
    scanf("%d", &x);
    Insert(Root, x, 0, i);
  }
  long long last = 0;
  for (int i = 1; i <= m; i++) {
    long long t, cnt = 0;
    scanf("%I64d", &t);
    int a, b;
    scanf("%d%d", &a, &b);
    Work(t);
    if (!Root) {
      long long lt = Heap[1].Time;
      Work(lt);
      cnt = lt - t;
    } else
      cnt = max(0LL, last - t);
    Tnode *Prev = Find_prev(Root, a, oo, maxn, NULL);
    if (Prev) Prev = Find_succ(Root, Prev->val - 1, oo, maxn, NULL);
    Tnode *Succ = Find_succ(Root, a, -oo, -maxn, NULL);
    if (Prev && Succ) {
      int dis_P = a - Prev->val, dis_S = Succ->val - a;
      if (dis_P < dis_S || (dis_P == dis_S && (Prev->stime < Succ->stime ||
                                               (Prev->stime == Succ->stime &&
                                                Prev->id < Succ->id))))
        Succ = NULL;
      else
        Prev = NULL;
    }
    if (!Prev) Prev = Succ;
    last = t + cnt;
    cnt += (max(Prev->val - a, a - Prev->val));
    printf("%d %I64d\n", Prev->id, cnt);
    cnt = t + cnt + (long long)max(a - b, b - a);
    Heap_Insert(cnt, b, Prev->id);
    Delete(Root, Prev->val, Prev->stime, Prev->id);
  }
  return 0;
}
