fork download
  1. t=int(input())
  2. for _ in range(t):
  3. a,b,c=[int(i) for i in input().split()]
  4. ans=0
  5. while(b>=1 and c>=2):
  6. c-=2
  7. b-=1
  8. ans+=3
  9. while(a>=1 and b>=2):
  10. b-=2
  11. a-=1
  12. ans+=3
  13. print(ans)
Success #stdin #stdout 0.02s 9464KB
stdin
3
3 4 5
1 0 5
5 3 2
stdout
9
0
6