#include <bits/stdc++.h>
using namespace std;
template <typename T, typename U>
inline void smin(T &a, U b) {
  if (a > b) a = b;
}
template <typename T, typename U>
inline void smax(T &a, U b) {
  if (a < b) a = b;
}
template <class T>
inline void gn(T &first) {
  char c, sg = 0;
  while (c = getchar(), (c > '9' || c < '0') && c != '-')
    ;
  for ((c == '-' ? sg = 1, c = getchar() : 0), first = 0; c >= '0' && c <= '9';
       c = getchar())
    first = (first << 1) + (first << 3) + c - '0';
  if (sg) first = -first;
}
template <class T, class T1>
inline void gn(T &first, T1 &second) {
  gn(first);
  gn(second);
}
template <class T, class T1, class T2>
inline void gn(T &first, T1 &second, T2 &z) {
  gn(first);
  gn(second);
  gn(z);
}
template <class T>
inline void print(T first) {
  if (first < 0) {
    putchar('-');
    return print(-first);
  }
  if (first < 10) {
    putchar('0' + first);
    return;
  }
  print(first / 10);
  putchar(first % 10 + '0');
}
template <class T>
inline void printsp(T first) {
  print(first);
  putchar(' ');
}
template <class T>
inline void println(T first) {
  print(first);
  putchar('\n');
}
int power(int a, int b, int m, int ans = 1) {
  for (; b; b >>= 1, a = 1LL * a * a % m)
    if (b & 1) ans = 1LL * ans * a % m;
  return ans;
}
int N, K, M;
set<pair<long long, int> > cars[210000];
set<int> pos;
set<int>::iterator it;
priority_queue<pair<long long, int>, vector<pair<long long, int> >,
               greater<pair<long long, int> > >
    arrival;
int first[210000];
long long ready[210000];
bool cmp(int c1, int c2, int tar) {
  if (abs(first[c1] - tar) < abs(first[c2] - tar)) return true;
  if (abs(first[c1] - tar) > abs(first[c2] - tar)) return false;
  if (ready[c1] < ready[c2]) return true;
  if (ready[c1] > ready[c2]) return false;
  return c1 < c2;
}
int main() {
  gn(N, K, M);
  for (int i = 0; i < K; i++) {
    gn(first[i]);
    cars[first[i]].insert(pair<long long, int>(ready[i] = 0, i));
    pos.insert(first[i]);
  }
  for (int i = 0; i < M; i++) {
    long long t;
    int a, b, c = -1;
    gn(t, a, b);
    while (!arrival.empty() && arrival.top().first <= t) {
      pair<long long, int> p = arrival.top();
      arrival.pop();
      cars[first[p.second]].insert(p);
      pos.insert(first[p.second]);
    }
    if (pos.empty()) {
      long long t1 = arrival.top().first;
      while (!arrival.empty() && arrival.top().first <= t1) {
        pair<long long, int> p = arrival.top();
        arrival.pop();
        cars[first[p.second]].insert(p);
        pos.insert(first[p.second]);
      }
    }
    it = pos.lower_bound(a);
    if (it != pos.end()) {
      c = cars[*it].begin()->second;
    }
    if (it != pos.begin()) {
      it--;
      int c1 = cars[*it].begin()->second;
      if (c == -1 || cmp(c1, c, a)) c = c1;
    }
    long long take_time = max(ready[c], t) + abs(first[c] - a);
    printsp(c + 1);
    println(take_time - t);
    cars[first[c]].erase(pair<long long, int>(ready[c], c));
    if (cars[first[c]].empty()) pos.erase(first[c]);
    first[c] = b;
    arrival.push(pair<long long, int>(ready[c] = take_time + abs(b - a), c));
  }
  return 0;
}
