#include using namespace std; using vc = std::vector ; using mat = vector; mat prod(const mat& A, const mat& B) { mat ret(A.size(), vc(B[0].size())); for (int i = 0; i < A.size(); i ++) { for (int j = 0; j < B[0].size(); j ++) { ret[i][j] = 0; for (int k = 0; k < A[0].size(); k ++) { ret[i][j] += A[i][k] * B[k][j]; } } } return ret; } int main () { mat A(2, vc(2)), B(2, vc(2)); for (auto& a : A) { for (auto& b : a) { cin >> b; } } for (auto& a : A) { for (auto& b : a) { cin >> b; } } int p = 67; mat P = {{0, 0}, {0, 0}}; for (;P[0][0] < p; P[0][0] ++) { for (;P[0][1] < p; P[0][1] ++) { for (;P[1][0] < p; P[1][0] ++) { for (;P[1][1] < p; P[1][1] ++) { auto ap = prod(P, A); auto pb = prod(B, P); bool ok = true; for (int i = 0; i < 2; i ++) { for (int j = 0; j < 2; j ++) { ok = ok && (ap[i][j] % p == pb[i][j]); } } if (ok) { puts("Yes"); return 0; } } } } } puts("No"); }