import Control.Monad
import Data.List as List
import Debug.Trace
import Data.Map as Map hiding (map, filter)
import Data.Sequence (elemIndexR)

type Region = (Int, Int, Int, Int)

main = do
  n <- liftM read getLine
  replicateM n analyze

analyze = do
  [h, w] <- liftM (map read . words) getLine
  image <- getImage h w
  let (suspicious, m) = nonRect image
  let (suspicious', _) = nonRect $ transpose image
  let tiles = nub $ concat $ image
  let loops = any (\a -> overlayLoops image tiles a []) tiles
  putStrLn $ if suspicious || suspicious' || loops then "SUSPICIOUS" else "SAFE"

overlayLoops image tiles a visited =
  any (\b -> b `elem` visited || overlayLoops image tiles b (b:visited)) $ filter (\b -> overlays image b a) $ filter ((/=) a) tiles

-- a overlays b
overlays :: [[Char]] -> Char -> Char -> Bool
overlays image a b =
  let y0 = minimum $ findIndices (elem b) image
      y1 = maximum $ findIndices (elem b) image
      x0 = minimum $ concatMap (elemIndices b) image
      x1 = maximum $ concatMap (elemIndices b) image
  in a `elem` [ image !! y !! x | y <- [y0..y1], x <- [x0..x1] ]

nonRect :: [[Char]] -> (Bool, Map (Char, Char) Int)
nonRect xs = nonRect' (zipWith (\xs ys -> xs `zip` ys) (init xs) (tail xs)) 0 empty

nonRect' :: [[(Char, Char)]] -> Int -> Map (Char, Char) Int -> (Bool, Map (Char, Char) Int)
nonRect' [] _ m = (False, m)
nonRect' (trans:tt) i m =
  let (newM, ok) = List.foldl ( \(m, ok) (x, y) ->
                            if not ok
                              then (m, False)
                              else
                                if x == y
                                  then (m, True)
                                  else if i /= findWithDefault i (x, y) m
                                    then (m, False)
                                    else (Map.insert (x, y) i m, True)
                          ) (m, True) trans
  in
    if not ok
      then (True, newM)
      else nonRect' tt (i+1) newM

getImage h w = do
  replicateM h getLine