#include <cstdio>
#include <cmath>
#include <cassert>
#include <vector>
#include <map>
#define infile "zzid.in"
#define outfile "zzid.out"
#define hMax 100013

using namespace std;

map <int, int> occurrences;
vector <int> v[hMax];
int h, w, bricks;
int maxOccurrences;
int diffMin;

void read() {
    scanf("%d %d", &h, &w);
    assert(2 <= h && h <= 100*1000);
    assert(2 <= w && w <= 1000*1000*1000);

    for (int i = 0; i < h; ++i) {
        int n;
        scanf("%d", &n);
        bricks += n;

        for (int j = 0; j < n; ++j) {
            int x;
            scanf("%d", &x);
            assert(1 <= x && x <= w);
            v[i].push_back(x);
        }
    }

    assert(bricks <= 1000*1000);
}

int getDifference(int x, int y) {
    return abs(x - y);
}

void solve() {
    for (int i = 0; i < h; ++i) {
        int sum = 0;

        for (unsigned j = 0; j < v[i].size() - 1; ++j) {
            sum += v[i][j];
            occurrences[sum]++;
        }

        assert(sum + v[i][v[i].size() - 1] == w);
    }

    for (map <int, int>::iterator it = occurrences.begin(); it != occurrences.end(); ++it) {
        if (it->second > maxOccurrences || (it->second == maxOccurrences && getDifference(it->first, w - it->first) < diffMin)) {
            maxOccurrences = it->second;
            diffMin = getDifference(it->first, w - it->first);
        }
    }
}

void write() {
    printf("%d %d\n", h - maxOccurrences, diffMin);
}

int main() {
    freopen(infile, "r", stdin);
    freopen(outfile, "w", stdout);

    read();
    solve();
    write();

    fclose(stdin);
    fclose(stdout);
    return 0;
}
