This page is still under construction.

Parts of this page are still being built. What you see may change.

Polyhedron

Time limit5sMemory limit256 MB

Summary
For each test case, compute the face count of a convex polyhedron from V and E with Euler formula F = 2 - V + E.
Level

Easy1 of 10

Topics
Math
Solved
No attempts yet

Problem

A mathematician carved a sphere into a convex polyhedron. Writing VV for the number of vertices, EE for the number of edges and FF for the number of faces, he knows that every convex polyhedron satisfies V−E+F=2V - E + F = 2. Carving spheres is his hobby, so when he writes down a record he counts only the vertices and the edges and never the faces.

Given the recorded VV and EE, find the number of faces of the convex polyhedron.

Input

The first line contains a natural number TT. (1≤T≤1001 \le T \le 100)

Each of the next TT lines contains two natural numbers VV and EE separated by a space. (4≤V≤1004 \le V \le 100, 4≤E≤1004 \le E \le 100) VV is the number of vertices and EE is the number of edges.

Output

For each VV and EE, print the number of faces of the convex polyhedron on its own line.

Examples3

  1. Example 1

    Input
    2
    8 12
    4 6
    
    Expected output
    6
    4
    
  2. Example 2

    Input
    1
    4 6
    
    Expected output
    4
    
  3. Example 3

    Input
    5
    4 6
    8 12
    6 12
    20 30
    12 30
    
    Expected output
    4
    6
    8
    12
    20