#include <bits/stdc++.h>
using namespace std;
const long long mod = 1000000007;
long long powmod(long long a, long long b) {
  long long res = 1;
  a %= mod;
  assert(b >= 0);
  for (; b; b >>= 1) {
    if (b & 1) res = res * a % mod;
    a = a * a % mod;
  }
  return res;
}
int n, k, m, x, a, b;
long long t, T;
set<pair<int, pair<long long, int>>> wc;
set<pair<long long, pair<int, int>>> rc;
int main() {
  scanf("%d%d%d", &n, &k, &m);
  for (int i = 1; i < k + 1; i++)
    scanf("%d", &x), wc.insert(make_pair(x, make_pair(0, i)));
  for (int i = 0; i < m; i++) {
    scanf("%lld%d%d", &t, &a, &b);
    T = max(T, t);
    while (!rc.empty() && rc.begin()->first <= T) {
      int id = rc.begin()->second.first;
      int pos = rc.begin()->second.second;
      wc.insert(make_pair(pos, make_pair(rc.begin()->first, id)));
      rc.erase(rc.begin());
    }
    if (wc.empty()) {
      T = max(T, rc.begin()->first);
      while (!rc.empty() && rc.begin()->first <= T) {
        int id = rc.begin()->second.first;
        int pos = rc.begin()->second.second;
        wc.insert(make_pair(pos, make_pair(rc.begin()->first, id)));
        rc.erase(rc.begin());
      }
    }
    auto rit = wc.lower_bound(make_pair(a, make_pair(0, 0)));
    pair<int, pair<long long, int>> carl, carr;
    if (rit == wc.end())
      carr = make_pair((1 << 30), make_pair(0, 0));
    else
      carr = *rit;
    auto lit = wc.lower_bound(make_pair(a + 1, make_pair(0, 0)));
    if (lit == wc.begin()) {
      carl = make_pair(-(1 << 30), make_pair(0, 0));
    } else {
      --lit;
      int pos = lit->first;
      lit = wc.lower_bound(make_pair(pos, make_pair(0, 0)));
      carl = *lit;
    }
    if (a - carl.first < carr.first - a ||
        (a - carl.first == carr.first - a && carl.second < carr.second))
      swap(carl, carr);
    printf("%d %lld\n", carr.second.second, T + abs(carr.first - a) - t);
    wc.erase(carr);
    rc.insert(make_pair(T + abs(carr.first - a) + abs(a - b),
                        make_pair(carr.second.second, b)));
  }
}
