#include <bits/stdc++.h>
void Solve();
int main() { Solve(); }
using namespace std;
long long n, k, m;
set<pair<long long, long long>> q[200002];
set<long long> av;
vector<pair<long long, long long>> ans;
deque<pair<long long, pair<long long, long long>>> waiting;
map<long long, pair<vector<pair<long long, long long>>,
                    vector<pair<long long, long long>>>>
    events;
void assign(long long i, long long t, long long a, long long b) {
  assert(!av.empty());
  auto it = av.upper_bound(a);
  auto jt = it == av.begin() ? it : prev(it);
  if (it == av.end()) --it;
  long long l = *it, r = *jt;
  if (abs(l - a) > abs(r - a)) swap(l, r);
  if (abs(l - a) == abs(r - a) && l != r) {
    if (*q[l].begin() > *q[r].begin()) l = r;
  }
  long long driver = q[l].begin()->second;
  long long wf = q[l].begin()->first;
  q[l].erase(q[l].begin());
  if (q[l].empty()) av.erase(l);
  long long s = max(wf, t);
  ans[i] = {driver, s - t + abs(l - a)};
  events[s + abs(l - a) + abs(b - a)].second.emplace_back(driver, b);
}
void Solve() {
  for (; cin >> n >> k >> m;) {
    for (long long i = (0); i < (n); i++) q[i].clear();
    av.clear();
    ans.resize(m);
    waiting.clear();
    events.clear();
    for (long long i = (0); i < (k); i++) {
      long long x;
      cin >> x;
      q[x].emplace(0, i + 1);
      av.insert(x);
    }
    for (long long i = (0); i < (m); i++) {
      long long t, a, b;
      cin >> t >> a >> b;
      events[t].first.emplace_back(a, b);
    }
    long long e = 0;
    for (auto it : events) {
      long long t = it.first;
      for (auto jt : it.second.second) {
        long long driver = abs(jt.first);
        q[jt.second].emplace(t, driver);
        av.insert(jt.second);
      }
      while (waiting.size() > 0 && av.size() > 0) {
        auto cur = waiting.front();
        waiting.pop_front();
        assign(e++, cur.first, cur.second.first, cur.second.second);
      }
      for (auto jt : it.second.first) {
        if (av.empty()) {
          waiting.emplace_back(t, jt);
        } else {
          long long a = jt.first, b = jt.second;
          assert(waiting.size() == 0);
          assign(e++, t, a, b);
        }
      }
    }
    assert(waiting.size() == 0);
    for (auto it : ans) cout << it.first << ' ' << it.second << '\n';
  }
}
