#include<iostream>
#include<cstdio>
using namespace std;
int main()
{
int a, b;
cin >> a >> b;
int c[121][113];
for (int i = 0; i < a; i++)
{
int count = 0;
for (int j = 0; j < a; j++)
{
cin >> c[i][j];
if (c[i][j] > b || c[i][j] < 0)
{
c[i][j] = -1;
count++;
}
}
int sum = 0, max = -1, mix = b + 1;
for (int j = 1; j < a; j++)
{
if (c[i][j] != -1)
{
if (c[i][j] > max)
max = c[i][j];
if (c[i][j] < mix)
mix = c[i][j];
sum += c[i][j];
}
}
sum = sum - max - mix;
sum = sum / (a - 3 - count);
sum = (sum + c[i][0] + 1) / 2;
cout << sum << endl;
sum = 0; max = -1; mix = b + 1;
}
return 0;
}
#include<cstdio>
using namespace std;
int main()
{
int a, b;
cin >> a >> b;
int c[121][113];
for (int i = 0; i < a; i++)
{
int count = 0;
for (int j = 0; j < a; j++)
{
cin >> c[i][j];
if (c[i][j] > b || c[i][j] < 0)
{
c[i][j] = -1;
count++;
}
}
int sum = 0, max = -1, mix = b + 1;
for (int j = 1; j < a; j++)
{
if (c[i][j] != -1)
{
if (c[i][j] > max)
max = c[i][j];
if (c[i][j] < mix)
mix = c[i][j];
sum += c[i][j];
}
}
sum = sum - max - mix;
sum = sum / (a - 3 - count);
sum = (sum + c[i][0] + 1) / 2;
cout << sum << endl;
sum = 0; max = -1; mix = b + 1;
}
return 0;
}