#include #include #include using namespace std; int n, m; string s; int hex(char c){ if(c >= '0' && c <= '9') return(c - '0'); return(c - 'A' + 10); } string press(string s) { int nb, mn, test; char c; string rs ="#", t = "0123456789ABCDEF"; for(int i = 1; i < s.length(); i+=2) { nb = hex(s[i])*16 + hex(s[i+1]); mn = 100000; c = 'h'; for(int j = 0; j < 16; j++) { test = j*16 + j; if(abs(nb - test) < mn) {mn = abs(nb - test); c = t[j];} } rs+= c; } return rs; } /* struct st{ string s; }a[100][100]; */ int main(){ cin >> n >> m; for(int i = 0; i < n; i++) { for(int j = 0; j < m; j++) { cin >> s; cout << press(s) << ' '; } cout << '\n'; } /* for(int i = 0; i < n; i++) { for(int j = 0; j < m; j++) { cout << a[i][j].s << ' '; } cout << '\n'; } */ return 0; }