#include <bits/stdc++.h>
using namespace std;
double getTime() { return clock() / (double)CLOCKS_PER_SEC; };
mt19937 rnd(
    std::chrono::high_resolution_clock::now().time_since_epoch().count());
const long long mod = 1e9 + 7;
const long long INF = 2e18;
const long long N = 2e5 + 5;
const long long P0 = 437;
const long long P1 = 343;
const long long d = 400;
const double PI = acos(-1);
set<pair<long long, long long> > wait[N];
void solve() {
  long long n, k, m;
  cin >> n >> k >> m;
  multiset<long long> cord;
  set<pair<long long, pair<long long, long long> > > when;
  vector<long long> x(k);
  for (long long i = 0; i < (k); i++) {
    cin >> x[i];
    x[i]--;
    wait[x[i]].insert({0, i});
    cord.insert(x[i]);
  }
  long long Time = 0;
  for (long long h = 0; h < (m); h++) {
    long long t, a, b;
    cin >> t >> a >> b;
    a--;
    b--;
    long long an_t = 0;
    while (((long long)(when).size())) {
      auto it = when.begin();
      long long time = it->first, C = it->second.first, id = it->second.second;
      if (time <= t) {
        cord.insert(C);
        wait[C].insert({time, id});
        when.erase(it);
      } else
        break;
    }
    if (!((long long)(cord).size())) {
      long long ntime = when.begin()->first;
      an_t = ntime - t;
      Time = ntime;
      while (((long long)(when).size())) {
        auto it = when.begin();
        long long time = it->first, C = it->second.first,
                  id = it->second.second;
        if (time == ntime) {
          cord.insert(C);
          wait[C].insert({time, id});
          when.erase(it);
        } else
          break;
      }
    }
    an_t = max(an_t, Time - t);
    auto itr = cord.lower_bound(a);
    auto itl = itr;
    itl--;
    bool fl = false;
    long long nice = INF;
    if (itr != cord.end()) nice = *itr;
    if (itr != cord.begin() && a - *itl <= nice - a) {
      if (a - *itl == nice - a) fl = true;
      nice = *itl;
    }
    if (fl) {
      auto it1 = wait[*itl].begin(), it2 = wait[*itr].begin();
      auto o1 = *it1, o2 = *it2;
      if (o2 < o1) nice = *itr;
    }
    auto it = wait[nice].begin();
    long long time = it->first, id = it->second;
    an_t += abs(nice - a);
    cout << id + 1 << ' ' << an_t << '\n';
    cord.erase(cord.find(nice));
    wait[nice].erase(it);
    when.insert({t + an_t + abs(b - a), {b, id}});
  }
}
signed main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long qq = 1;
  while (qq--) solve();
}
