#include <iostream>
#include <bitset>
using namespace std;

int main() {
    int n, m, q;
    cin >> n >> m >> q;
    bitset<49> a, b[7];
    string s, t;
    for (int i = 1; i <= n; i++)
        cin >> t, s += t;
    a = bitset<49>(s);
    for (int k = 0; k < q; k++) {
        s = "";
        for (int i = 1; i <= n; i++)
            cin >> t, s += t;
        b[k] = bitset<49>(s);
    }
    int mn = q + 1, res;
    for (int i = 0; i < 1 << q; i++) {
        if (__builtin_popcount(i) >= mn)
            continue;
        bitset<49> ans;
        for (int j = 0; j < q; j++)
            if (i >> j & 1)
                ans |= b[j];
        if ((ans | a) == (1ll << m * n) - 1 && (ans & a) == 0)
            mn = __builtin_popcount(i), res = i;
    }
    if (mn == q + 1)
        mn = -1;
    cout << mn << '\n';
    if (mn != -1) {
        for (int j = 0; j < q; j++)
            if (res >> j & 1)
                cout << j + 1 << ' ';
        cout << '\n';
    }

    return 0;
}