#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<map>
#include<stack>
#include<cmath>
#include<iomanip>
#include<set>
#include<numeric>
#include<sstream>
#include<random>
#include<cassert>
#include<climits>
#include<cstring>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < n; ++i)
#define rrep(i, st, n) for (int i = st; i < n; ++i)
using pii = pair<int, int>;
const int inf = 1e9 + 7;
int dy[] = {0, 0, -1, 1, -1, 1, -1, 1};
int dx[] = {1, -1, 0, 0, -1, 1, 1, -1};
#define ceil(a, b) a / b + !!(a % b)
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)

struct Node {
    char self;
    set<char> parent;
};
int l, r, u, b;
int h, w;
char table[51][51];
queue<pii> q;
int reached[51][51];
int num = 0;
Node node[7];
int flg = 0;
set<char> s;
int check[7];
map<char, int> mp;

void getlrub(char e) {
    reached[q.front().first][q.front().second] = 1;
    while (!q.empty()) {
        int y = q.front().first;
        int x = q.front().second;
        q.pop();
        rep(i, 4) {
            int ny = y + dy[i];
            int nx = x + dx[i];
            if (ny >= h || ny < 0 || nx >= w || nx < 0) continue;
            if (reached[ny][nx] || table[ny][nx] != e) continue;
            //if (e == 'A') cout << ny << " " << nx << endl;
            reached[ny][nx] = 1;
            chmin(l, nx); chmax(r, nx); chmax(u, ny); chmin(b, ny);
            q.push({ny, nx});
        }
    }
}
int aftergetlrub(char e) {
    //cout << l << " " << r << " " << b << " " << u << endl;
    rep(i, h) {
        rep(j, w) {
            if (i >= b && i <= u && j >= l && j <= r) {
                if (table[i][j] != e) {
                    node[num].parent.insert(table[i][j]);
                }
                if (table[i][j] == '.') {
                    return -1;
                }
            }
        }
    }
    return 0;
}
void check_() {
    rep(i, s.size()) {
        cout << "self " << node[i].self << endl;
        for (auto e2 : node[i].parent) cout << e2 << " ";
        cout << endl;
    }
}
int getinfiniteloop() {
    queue<char> qq;
    int count = 0;
    rep(i, s.size()) {
        for (auto e : node[i].parent) {
            qq.push(e);
        }
        while (!qq.empty()) {
            char now = qq.front();
            qq.pop();
            for (auto e : node[mp[now]].parent) {
                qq.push(e);
                count++;
                //cout << count << endl;
                if (count > 100) return -1;
            }
        }
    }
    return 0;
}
int main() {
    int n; cin >> n;
    while (n--) {
        flg = 0;
        //cout << n << endl;
        cin >> h >> w;
        s.clear();
        rep(i, h) rep(j, w) {cin >> table[i][j]; if (table[i][j] != '.') s.insert(table[i][j]);}
        num = 0;
        for (auto e : s) {
            node[num].self = e;
            node[num].parent.clear();
            num++;
        }
        if (num == 0) {cout << "SAFE" << endl; continue;}
        num = 0;
        for (auto e : s) {
            l = inf; r = -inf; u = -inf; b = inf;
            rep(i, h) rep(j, w) reached[i][j] = 0;
            rep(i, h) {
                rep(j, w) {
                    if (table[i][j] == e && reached[i][j] == 0) {
                        //cout << i << " " << j << endl;
                        q.push({i, j}); //y, x
                        chmin(l, j); chmax(r, j); chmax(u, i); chmin(b, i);
                        getlrub(e);
                    }
                }
            }
            if (aftergetlrub(e) == -1) {
                cout << "SUSPICIOUS" << endl;
                flg = 1;
                break;
            }
            num++;
        } //for (auto e : s)
        if (flg) continue;
        //check_();
        //すべての点をみて、親を辿ると無限ループになるやつ探す
        int c = 0;
        mp.clear();
        for (auto e : s) mp[e] = c++;
        if (getinfiniteloop() == -1) cout << "SUSPICIOUS" << endl;
        else cout << "SAFE" << endl;
    } //datasets
}




Measured memory_bytes: 3172