fork download
  1. #include <cstring>
  2. #include <cmath>
  3. #include <algorithm>
  4. #include <cstdlib>
  5. #include <cstdio>
  6. #include <iostream>
  7. #include <fstream>
  8. #include <queue>
  9.  
  10. #define rep(i, l, r) for(int i = l; i <= r; i++)
  11. #define down(i, l, r) for(int i = l; i >= r; i--)
  12. #define MS 1234
  13. #define MAX 1037471823
  14.  
  15. using namespace std;
  16.  
  17. int t, n, m, a, b, c;
  18.  
  19. int main()
  20. {
  21. scanf("%d", &t);
  22. while (t-- > 0)
  23. {
  24. scanf("%d", &n);
  25. a = b = c = 0;
  26. rep(i, 1, n)
  27. {
  28. scanf("%d", &m);
  29. if (m == 1) a++; else b++;
  30. c = c ^ m;
  31. }
  32. if ((c > 0 && (b > 0)) || (c == 0 && (b == 0))) printf("John\n"); else printf("Brother\n");
  33. }
  34. }
Success #stdin #stdout 0s 3344KB
stdin
1
5
1 2 3 4 5
stdout
John