#include <bits/stdc++.h>

using namespace std;
#define sz(a) (int)(a).size()
#define rep(i, a, b) for (int i = (a), _b = (b); i < _b; ++i)
#define debug(a) cerr << #a << ": " << (a) << '\n';
#define debug_arr(a, n) { cerr << #a << " "; rep(i, 0, n) cerr << a[i] << " \n"[(i + 1) == n]; }
#define debug_two(a, b) cerr << #a << ": " << (a) << ", " << #b << ": " << (b) << '\n';
typedef long long int64;

template <typename num_t>
inline void add_mod(num_t& a, const long long& b, const int& m) { a = (a + b) % m; if (a < 0) a += m; }
template <typename num_t>
inline bool update_max(num_t& a, const num_t& b) { return a < b ? a = b, true : false; }
template <typename num_t>
inline bool update_min(num_t& a, const num_t& b) { return a > b ? a = b, true : false; }
template <typename num_t>
num_t gcd(num_t lhs, num_t rhs) { return !lhs ? rhs : gcd(rhs % lhs, lhs); }
template <typename num_t>
num_t pw(num_t n, num_t k, num_t mod) {
  num_t res = 1; for (; k > 0; k >>= 1) { if (k & 1) res = 1ll * res * n % mod; n = 1ll * n * n % mod; } return res;
}
int invserse_mod(int n, int mod) { return pw(n, mod - 2, mod); }

void solve() {
  int n, k;
  cin >> n >> k;
  vector<vector<int>> pos(k, vector<int>(n, 0));
  vector<int64> sum(k, 0);
  vector<int64> sum_square(k, 0);

  rep(i, 0, k) {
    rep(j, 0, n) { 
      cin >> pos[i][j];
      sum[i] += pos[i][j];
      sum_square[i] += 1ll * pos[i][j] * pos[i][j];
    }
  }

  const auto& end_pos = pos.back();
  const auto& begin_pos = pos[0];

  int64 total_speed = 0;
  rep(i, 0, n) total_speed += end_pos[i] - begin_pos[i];
  total_speed /= (k - 1);

  int funny_col = 0;
  rep(col, 1, k) {
    int cur_diff = 0;
    rep(j, 0, n) cur_diff += pos[col][j] - pos[col - 1][j];
    if (cur_diff != total_speed) {
      funny_col = col;
      break;
    }
  }

  vector<int> chosen_cols;
  if (funny_col > 2) 
    chosen_cols = {0, 1, 2};
  else 
    chosen_cols = {funny_col + 1, funny_col + 2, funny_col + 3};
  
  auto get_sum_speed_square = [&](vector<int> cols) -> int64 {
    int64 first_diff = sum_square[cols[1]] - sum_square[cols[0]];
    int64 second_diff = sum_square[cols[2]] - sum_square[cols[1]];
    return (second_diff - first_diff) / 2;
  };

  auto speed_square = get_sum_speed_square(chosen_cols);

  int lhs = funny_col - 1, rh = funny_col + 1;
  int64 origin_sum_square = (sum_square[lhs] + sum_square[rh] - 2 * speed_square) / 2;
  debug_two(origin_sum_square, sum_square[funny_col]);

  int64 speed_diff = sum[funny_col] - sum[funny_col - 1] - total_speed;
  int64 speed_square_diff = sum_square[funny_col] - origin_sum_square;

  debug_two(speed_diff, speed_square_diff);
  cout << funny_col << ' ';
  // (x + diff) ^ 2 - x ^ 2 = 2 * x * diff + diff ^ 2

  int64 original = (speed_square_diff - speed_diff * speed_diff) / 2 / speed_diff;
  cout << original << '\n';
  cout.flush();
}

int main() {
  ios_base::sync_with_stdio(0); cin.tie(0);
#ifdef _LOCAL_
  freopen("in.txt", "r", stdin);
#endif
  const bool multiple_test = false;
  int test = 1;
  if (multiple_test)
    cin >> test;

  for(int i = 0; i < test; ++i) {
    //printf("Case #%d: ", i + 1);
    solve();
  }
#ifdef _LOCAL_
  cerr << "\n" << 1.0 * clock() / CLOCKS_PER_SEC << "\n";
#endif
}
