//#include #include #include #include using namespace std; //ifstream cin ("compress.in"); ofstream cout ("compress.out"); string s; inline int val (char c) { if ('0' <= c && c <= '9') { return c - '0'; } return c - 'A' + 10; } int main() { int n, m; cin >> n >> m; for (int i = 1; i <= n; ++ i) { for (int j = 1; j <= m; ++ j) { cin >> s; cout << "#"; for (int k = 2; k <= 6; k += 2) { int nr = val(s[k - 1]) * 16 + val(s[ k ]); int mndif, lit; mndif = 1 << 30; for (int shp = 0; shp < 16; ++ shp) { if (mndif > abs(nr - 17 * shp)) { lit = shp; mndif = abs(nr - 17 * shp); } } char aux; if (lit < 10) aux = lit + '0'; else aux = lit - 10 + 'A'; cout << aux; } cout << " "; } cout << "\n"; } return 0; }