import Control.Applicative ((<$>), (<*>))
import Control.Monad
import Data.List
-- import Test.HUnit

main :: IO ()
-- main = runTestTT (TestList tests) >> return ()
main = do
  n <- getl toInt
  solve <$> replicateM n (getl $ wrds toInt) >>= mapM_ print

solve :: [[Int]] -> [Int]
solve = map formation

formation :: [Int] -> Int
formation [c,a,n] = f (c,a,n) 0
  where
    f (x, y, z) c
      | x < 0 || y < 0 || z < 0 = c - 1
      | otherwise = maximum [f (x-3, y, z) (c+1), f (x-2, y-1, z) (c+1), f (x-1, y-1, z-1) (c+1)]

toInt :: String -> Int
toInt = read

wrds :: (String -> a) -> String -> [a]
wrds f = map f . words

getl :: (String -> a) -> IO a
getl f = f <$> getLine


-- tests :: [Test]
-- tests = [
--   "f1" ~: formation [3,0,0] ~?= 1,
--   "f2" ~: formation [1,1,1] ~?= 1,
--   "f3" ~: formation [9,4,1] ~?= 4
--   ]