description: A tree is a connected graph without cycles. A rooted tree has a special vertex called the root. The parent of a vertex v (different from root) is the previous to v vertex on the shortest path from the root to the vertex v. Children of the vertex v are all vertices for which v is the parent.
  
  A vertex is a leaf if it has no children. We call a vertex a bud, if the following three conditions are satisfied: 
  
    * it is not a root, 
    * it has at least one child, and 
    * all its children are leaves. 
  
  
  
  You are given a rooted tree with n vertices. The vertex 1 is the root. In one operation you can choose any bud with all its children (they are leaves) and re-hang them to any other vertex of the tree. By doing that you delete the edge connecting the bud and its parent and add an edge between the bud and the chosen vertex of the tree. The chosen vertex cannot be the bud itself or any of its children. All children of the bud stay connected to the bud.
  
  What is the minimum number of leaves it is possible to get if you can make any number of the above-mentioned operations (possibly zero)?
  
  Input
  
  The input consists of multiple test cases. The first line contains a single integer t (1 ≤ t ≤ 10^4) — the number of test cases. Description of the test cases follows.
  
  The first line of each test case contains a single integer n (2 ≤ n ≤ 2 ⋅ 10^5) — the number of the vertices in the given tree.
  
  Each of the next n-1 lines contains two integers u and v (1 ≤ u, v ≤ n, u ≠ v) meaning that there is an edge between vertices u and v in the tree.
  
  It is guaranteed that the given graph is a tree.
  
  It is guaranteed that the sum of n over all test cases doesn't exceed 2 ⋅ 10^5.
  
  Output
  
  For each test case print a single integer — the minimal number of leaves that is possible to get after some operations.
  
  Example
  
  Input
  
  
  5
  7
  1 2
  1 3
  1 4
  2 5
  2 6
  4 7
  6
  1 2
  1 3
  2 4
  2 5
  3 6
  2
  1 2
  7
  7 3
  1 5
  1 3
  4 6
  4 7
  2 1
  6
  2 1
  2 3
  4 5
  3 4
  3 6
  
  
  Output
  
  
  2
  2
  1
  2
  1
  
  Note
  
  In the first test case the tree looks as follows:
  
  <image>
  
  Firstly you can choose a bud vertex 4 and re-hang it to vertex 3. After that you can choose a bud vertex 2 and re-hang it to vertex 7. As a result, you will have the following tree with 2 leaves:
  
  <image>
  
  It can be proved that it is the minimal number of leaves possible to get.
  
  In the second test case the tree looks as follows:
  
  <image>
  
  You can choose a bud vertex 3 and re-hang it to vertex 5. As a result, you will have the following tree with 2 leaves:
  
  <image>
  
  It can be proved that it is the minimal number of leaves possible to get.
solution: import java.io.OutputStream;
  import java.io.IOException;
  import java.io.InputStream;
  import java.io.PrintWriter;
  import java.util.List;
  import java.util.InputMismatchException;
  import java.io.IOException;
  import java.io.InputStream;
  import java.util.ArrayList;
  
  /**
   * Built using CHelper plug-in
   * Actual solution is at the top
   */
  public class Main {
      public static void main(String[] args) {
          InputStream inputStream = System.in;
          OutputStream outputStream = System.out;
          InputReader in = new InputReader(inputStream);
          PrintWriter out = new PrintWriter(outputStream);
          EPeresadkaPochek solver = new EPeresadkaPochek();
          int testCount = Integer.parseInt(in.next());
          for (int i = 1; i <= testCount; i++)
              solver.solve(i, in, out);
          out.close();
      }
  
      static class EPeresadkaPochek {
          public EPeresadkaPochek.Res doit(Vertex cur, Vertex ignore) {
  
              boolean found = false;
              boolean nonLeave = false;
              int cmp = 0;
              int leaves = 0;
              for (Vertex v : cur.adj) {
                  //noinspection ObjectEquality
                  if (v == ignore) {
                      continue;
                  }
                  EPeresadkaPochek.Res res = doit(v, cur);
                  if (res.type != EPeresadkaPochek.Type.NONE) {
                      found = true;
                  }
                  if (res.type == EPeresadkaPochek.Type.FULL) {
                      nonLeave = true;
                  }
                  cmp += res.cmp;
                  leaves += res.leaves;
              }
              if (!found) {
                  return new EPeresadkaPochek.Res(EPeresadkaPochek.Type.LEAVE, cmp, cur.idx == 0 ? leaves : leaves + 1);
              }
              if (!nonLeave) {
                  return new EPeresadkaPochek.Res(EPeresadkaPochek.Type.NONE, cmp + 1, leaves);
              }
              return new EPeresadkaPochek.Res(EPeresadkaPochek.Type.FULL, cmp, leaves);
          }
  
          public void solve(int testNumber, InputReader in, PrintWriter out) {
              int n = in.nextInt();
              Vertex[] vs = Vertex.emptyGraph(n);
              for (int i = 0; i < n - 1; i++) {
                  int from = in.nextInt() - 1;
                  int to = in.nextInt() - 1;
                  vs[from].adj.add(vs[to]);
                  vs[to].adj.add(vs[from]);
              }
              EPeresadkaPochek.Res res = doit(vs[0], null);
              out.println(res.leaves - res.cmp + 1);
          }
  
          public static class Res {
              EPeresadkaPochek.Type type;
              int cmp;
              int leaves;
  
              public Res(EPeresadkaPochek.Type type, int cmp, int leaves) {
                  this.type = type;
                  this.cmp = cmp;
                  this.leaves = leaves;
              }
  
          }
  
          public static enum Type {
              NONE,
              LEAVE,
              FULL,
              ;
          }
  
      }
  
      static class Vertex {
          int idx;
          List<Vertex> adj = new ArrayList<>();
  
          public static Vertex[] emptyGraph(int n) {
              Vertex[] vs = new Vertex[n];
              for (int i = 0; i < n; i++) {
                  vs[i] = new Vertex();
                  vs[i].idx = i;
              }
              return vs;
          }
  
      }
  
      static class InputReader {
          private static final int BUFFER_LENGTH = 1 << 10;
          private InputStream stream;
          private byte[] buf = new byte[BUFFER_LENGTH];
          private int curChar;
          private int numChars;
  
          public InputReader(InputStream stream) {
              this.stream = stream;
          }
  
          private int nextC() {
              if (numChars == -1) {
                  throw new InputMismatchException();
              }
              if (curChar >= numChars) {
                  curChar = 0;
                  try {
                      numChars = stream.read(buf);
                  } catch (IOException e) {
                      throw new InputMismatchException();
                  }
                  if (numChars <= 0)
                      return -1;
              }
              return buf[curChar++];
          }
  
          public String next() {
              int c = nextC();
              while (isSpaceChar(c)) {
                  c = nextC();
              }
              StringBuilder res = new StringBuilder();
              do {
                  res.append((char) c);
                  c = nextC();
              } while (!isSpaceChar(c));
              return res.toString();
          }
  
          public int nextInt() {
              int c = skipWhileSpace();
              int sgn = 1;
              if (c == '-') {
                  sgn = -1;
                  c = nextC();
              }
              int res = 0;
              do {
                  if (c < '0' || c > '9') {
                      throw new InputMismatchException();
                  }
                  res *= 10;
                  res += c - '0';
                  c = nextC();
              } while (!isSpaceChar(c));
              return res * sgn;
          }
  
          public int skipWhileSpace() {
              int c = nextC();
              while (isSpaceChar(c)) {
                  c = nextC();
              }
              return c;
          }
  
          public boolean isSpaceChar(int c) {
              return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
          }
  
      }
  }
  
  