#include <bits/stdc++.h>
using namespace std;
int n, k, m;
map<int, priority_queue<pair<long long, int> > > M;
priority_queue<pair<long long, pair<int, int> > > Q;
void addCar(int x, long long tim, int ind) {
  auto it = M.find(x);
  if (it == M.end()) {
    priority_queue<pair<long long, int> > tmp;
    tmp.push(pair<long long, int>(-tim, -ind));
    M.insert(make_pair(x, tmp));
  } else
    it->second.push(pair<long long, int>(-tim, -ind));
}
void remCar(map<int, priority_queue<pair<long long, int> > >::iterator &it) {
  it->second.pop();
  if (it->second.empty()) M.erase(it);
}
pair<long long, int> getClose(int x, long long tim) {
  auto it2 = M.lower_bound(x);
  auto it = it2;
  if (it != M.begin()) {
    it--;
    if (it2 != M.end())
      if (x - it->first < it2->first - x ||
          x - it->first == it2->first - x &&
              it->second.top() > it2->second.top()) {
        pair<long long, int> res =
            pair<long long, int>(tim + x - it->first, -it->second.top().second);
        remCar(it);
        return res;
      } else {
        pair<long long, int> res = pair<long long, int>(
            tim + it2->first - x, -it2->second.top().second);
        remCar(it2);
        return res;
      }
    else {
      pair<long long, int> res =
          pair<long long, int>(tim + x - it->first, -it->second.top().second);
      remCar(it);
      return res;
    }
  } else {
    pair<long long, int> res =
        pair<long long, int>(tim + it2->first - x, -it2->second.top().second);
    remCar(it2);
    return res;
  }
}
int main() {
  scanf("%d %d %d", &n, &k, &m);
  for (int i = 1; i <= k; i++) {
    int x;
    scanf("%d", &x);
    addCar(x, 0, i);
  }
  long long gt = 0;
  for (int i = 1; i <= m; i++) {
    long long t;
    int a, b;
    scanf("%I64d %d %d", &t, &a, &b);
    while (!Q.empty() && -Q.top().first <= t) {
      pair<long long, pair<int, int> > p = Q.top();
      Q.pop();
      addCar(p.second.first, -p.first, p.second.second);
    }
    gt = max(gt, t);
    pair<long long, int> res;
    if (!M.empty())
      res = getClose(a, gt);
    else {
      gt = -Q.top().first;
      while (!Q.empty() && -Q.top().first == gt) {
        pair<long long, pair<int, int> > p = Q.top();
        Q.pop();
        addCar(p.second.first, -p.first, p.second.second);
      }
      res = getClose(a, gt);
    }
    printf("%d %I64d\n", res.second, res.first - t);
    res.first += abs(a - b);
    Q.push(pair<long long, pair<int, int> >(-res.first,
                                            pair<int, int>(b, res.second)));
  }
  return 0;
}
