#include #define endl '\n' using namespace std; const int maxN = 1005, maxM = 1005; bool p = true; int n, m; char matrix[maxN][maxM]; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); freopen("barcode.in", "r", stdin); freopen("barcode.out", "w", stdout); cin>>n>>m; for(int i = 0; i < n; i++) { for(int j = 0; j < m; j++) { cin>>matrix[i][j]; if(i != 0) { if(i != n - 1) { if(matrix[i][j] == '#' && matrix[i - 1][j] != '#') p = false; } else { if(matrix[i][j] > '9' || matrix[i][j] < '0') p = false; } } } } if(p) cout<<"BUY"<