#include <iostream>
#include <string>
using namespace std;

int main() {
    int r, c;
    string seats[100][100];
    cin >> r >> c;
    for (int i = 0; i < r; i++) {
        for (int j = 0; j < c; j++) {
            cin >> seats[i][j];
        }
    }
    string find;
    cin >> find;
    bool found = false;
    for (int i = 0; i < r; i++) {
        for (int j = 0; j < c; j++) {
            if (seats[i][j] == find) {
                found = true;
                cout << i + 1 << " " << j + 1 << endl;
            }
        }
    }
    if (!found) {
        cout << "0 0" << endl;
    }
    return 0;
}