#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <stack>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <bitset>
#include <sstream>
#include <iomanip>
using namespace std;


#define int int64_t
#define vi vector<int>
#define vb vector<bool>
#define vbb vector< vector<bool> >
#define all(x) (x).begin(), (x).end()
#define vii vector< vector<int> >
#define rip(dp, n, m) vector< vector<int> > dp(n, vector<int>(m,0))
#define ff first
#define ss second
#define pii pair<int64_t, int64_t>
#define miv map<int, vector<int> >
#define mp make_pair
#define pb push_back
#define prr(x) cout << (#x) <<'	' << (x) << endl
#define pr(x) cout  << (x) << endl
#define f(i,n) for(i=0;i<n;i++)
#define pqb priority_queue<int>
#define autoit(x,it) for(auto it = x.begin(); it != x.end(); it++)
#define autoitr(x,it) for(auto it = x.rbegin(); it != x.rend(); it++)
#define rep(n) for(ll i = 0; i < n; i++)
#define pqs priority_queue<int,vi,greater<int> >
#define setbits(x)  __builtin_popcountll(x)
#define zrobits(x)  __builtin_ctzll(x)
#define mod 1000000007
#define inf 1e18
#define ps(x,y) fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x) int x; cin>>x; while(x--)
#define FIO  ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int dr8[] = {1,1,0,-1,-1,-1, 0, 1};
int dc8[] = {0,1,1, 1, 0,-1,-1,-1};
int dr4[] = {1,0,0,-1};
int dc4[] = {0,1,-1,0};
int gcd(int a, int b)
{
    if(a%b==0) return b;
    return gcd(b, a%b);
}
void inp(int &x)
{
    bool neg=false;
    register int c;
    x =0;
    c=getchar();
    if(c=='-')
    {
        neg = true;
        c=getchar();
    }
    for(;(c>47 && c<58);c=getchar())
        x = (x<<1) + (x<<3) +c -48;
    if(neg)
    x *=-1;
}
void solve();

int32_t main()
{
    FIO;
    int t=1;
    //cin >> t;
for(int i=1;i<=t;i++)
    {
        solve();
    }
}
void solve()
{
    int i, n, j, m, k, l, t;
    cin >> n >> m;
    rip(dp,n,m);
    f(i,n) f(j,m) cin >> dp[i][j];
    k=inf;
    f(i,n) f(j,m) k = min(k,dp[i][j]);
    l=0;
    f(i,n) f(j,m) l += dp[i][j]-k;
    cout << l;
}
#include<bits/stdc++.h>
#define int long long
using namespace std;
const int maxn=3e6+5;
int n;
int c[maxn],k,now;
signed main() {
//	freopen("data.in","r",stdin);
//	freopen("data.out","w",stdout);
	cin>>n>>k;
	for(register int i=1; i<=3*n; i++)c[i]=i*(i-1)/2;
	for(register int t=3; t<=3*n; t++) {
		int w=c[t-1];
//		cout<<w<<endl;
		if(t>n+1)w-=c[t-n-1]*3;
		if(t>2*n)w+=c[t-2*n-1]*3;
//		cout<<t<<' '<<w<<endl;
		if(now+w>=k) {
//			cout<<t<<' '<<now<<' '<<k<<endl;
			for(register int i=1; i<=n; i++) {
				if(t-i<2||t-i>2*n)continue;
				int p=t-i,q=p-1;
				if(p>n)q-=(p-n-1)*2;
				if(now+q>=k) {
					if(p>n) {
						int cs=p-n;
						printf("%lld %lld %lld",i,k-now+cs-1,t-i-k+now-cs+1);
					} else printf("%lld %lld %lld",i,k-now,t-i-k+now);
					return 0;
				}
				now+=q;
			}
			return 0;
		}
		now+=w;
	}
	cout<<now<<' '<<k<<endl;
}