/* GCC */
#include <fstream>

using namespace std;

int main(void)
{
    size_t n, m, n1, m1, k, temp, sumk = 0, sum = 0;
    std::ifstream in("display.in");
    in >> n >> m >> n1 >> m1 >> k;
    for(size_t i = 0; i < n; i++)
    {
               for(size_t j = 0; j < m; j++)
               {
                          in >> temp;
                          sum += temp;
                          if(temp)
                                  sumk+=k;
               }
    }
    in.close();
    std::ofstream out("display.out");
    if(n1 == 1 && m1 == 1)
          out << sumk-sum;
    else if(sum % 2 != 0 && k % 2 == 0 && n1*m1 % 2 == 0)
           out << "impossible";
    else
        out << (n-1)*(m-1)*k/n1/m1+1;
    out << endl;
    out.close();
    return 0;
}
