/* Copyright (C) 2009 Igor V. Burago */

#include <cassert>
#include <fstream>

using namespace std;


int main()
{
    ifstream input("input.txt");
    ofstream output("output.txt");

    int rows_num;
    int cols_num;
    int block_size;
    assert(input >> rows_num >> cols_num >> block_size);
    assert(1 <= rows_num && rows_num <= 10000 && 1 <= cols_num && cols_num <= 10000);
    int total_size = rows_num * cols_num;
    assert(1 <= block_size && block_size <= total_size && total_size % block_size == 0);

    int row_min;
    int col_min;
    int row_max;
    int col_max;
    assert(input >> row_min >> col_min >> row_max >> col_max);
    assert(1 <= row_min && row_min <= rows_num && 1 <= col_min && col_min <= cols_num);
    assert(1 <= row_max && row_max <= rows_num && 1 <= col_max && col_max <= cols_num);
    assert(row_min <= row_max && row_max - row_min <= 100);
    assert(col_min <= col_max && col_max - col_min <= 100);

    int min_val = -1;
    int max_val = block_size;
    for (int row = row_min; row <= row_max; ++row)
    {
        int num = (row - 1) * cols_num + col_min - 1;
        for (int col = col_min; col <= col_max; ++col)
        {
            char color;
            assert(input >> color);
            assert(color == '=' || color == '.');
            int rem = num++ % block_size;
            if (color == '=')
                min_val = max(min_val, rem);
            else
                max_val = min(max_val, rem);
        }
    }

    int blocks_num = total_size / block_size;
    output << (min_val + 1) * blocks_num << " " << max_val * blocks_num << endl;

    return 0;
}
