#ifdef _MSC_VER
#define _CRT_SECURE_NO_WARNINGS
#endif //_MSC_VER

#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <vector>
#include <numeric>
#include <ctime>
#include <chrono>
#include <iostream>
#include <string>
#include <sstream>
#include <array>
#include <random>
#include <cmath>
#include <cassert>
#include <map>
#include <queue>
#include <stack>
#include <set>
#include <utility>
#include <bitset>
#include <functional>
#include <unordered_set>
#include <unordered_map>
#include <iomanip>

using ll = long long;

constexpr int MOD = 998244353;// // //;
//constexpr int MOD = 1000000000 + 7;

constexpr ll powm(ll x, ll n, ll mod)
{
	return (n == 0 ? 1 : powm(x*x%mod, n / 2, mod) * (n % 2 ? x : 1) % mod);
} 
 
static int solve()
{	
	int  M, K;
	std::cin >> M >> K;
	std::vector<ll> sums(K), sumSqrs(K);
	for (int i = 0; i < K; ++i)
	{
		for (int j = 0; j < M; ++j) {
			int t;
			std::cin >> t;
			sums[i] += t;
			sumSqrs[i] += t * 1LL * t;
		}
	}


	ll a = sums[1] - sums[0];

	int j = 0;
	while (sums[j + 2] - sums[j + 1] != a)
	{
		a = sums[j + 2] - sums[j + 1];
		++j;
	}

	ll b = sums[j] - j * a;

	int t = 0;
	while (sums[t] == a * t + b)
		++t;

	j = t >= 3 ? 0 : 3;

	ll c = (sumSqrs[j] + sumSqrs[j + 2] - 2 * sumSqrs[j + 1]) / 2;
	ll d = sumSqrs[j + 1] - sumSqrs[j] - 2 * c*j - c;
	ll e = sumSqrs[j] - c * j  * j - d * j;
	ll dif_1 = sums[t] - a * t - b;
	ll dif_2 = sumSqrs[t] - c * t * t - d * t - e;
	ll orig = (dif_2 - dif_1 * dif_1) / (2 * dif_1);
	std::cout << t << " " << orig << std::endl;
	return 0;
}


int main(int argc, char* argv[])
{
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif //ONLINE_JUDGE
	std::ios::sync_with_stdio(false); std::cin.tie(0);std::cout.tie(0);	
	int tc = 1;
	//std::cin >> tc;
	for (int ic = 1; ic <= tc; ++ic)
	{
		solve();
	}

	return 0;
}
