🏡 index : github.com/captn3m0/codechef.git

---
category_name: easy
problem_code: ANUTHM
problem_name: 'Tojo hates probabilities'
languages_supported:
    - ADA
    - ASM
    - BASH
    - BF
    - C
    - 'C99 strict'
    - CAML
    - CLOJ
    - CLPS
    - 'CPP 4.3.2'
    - 'CPP 4.9.2'
    - CPP14
    - CS2
    - D
    - ERL
    - FORT
    - FS
    - GO
    - HASK
    - ICK
    - ICON
    - JAVA
    - JS
    - 'LISP clisp'
    - 'LISP sbcl'
    - LUA
    - NEM
    - NICE
    - NODEJS
    - 'PAS fpc'
    - 'PAS gpc'
    - PERL
    - PERL6
    - PHP
    - PIKE
    - PRLG
    - PYTH
    - 'PYTH 3.4'
    - RUBY
    - SCALA
    - 'SCM guile'
    - 'SCM qobi'
    - ST
    - TCL
    - TEXT
    - WSPC
max_timelimit: '1'
source_sizelimit: '50000'
problem_author: anudeep2011
problem_tester: xiaodao
date_added: 5-01-2015
tags:
    - anudeep2011
    - cook54
    - easy
    - maths
editorial_url: 'http://discuss.codechef.com/problems/ANUTHM'
time:
    view_start_date: 1421609400
    submit_start_date: 1421609400
    visible_start_date: 1421609400
    end_date: 1735669800
    current: 1493558106
layout: problem
---
All submissions for this problem are available.###  Read problems statements in [Mandarin Chinese](http://www.codechef.com/download/translated/COOK54/mandarin/ANUTHM.pdf) and [Russian](http://www.codechef.com/download/translated/COOK54/russian/ANUTHM.pdf) as well.

### Problem description

As a holiday gift, Tojo received a probability problem. The problem read as follows

Consider an **N** by **M** grid. Rows are numbered **1** to **N**, from top to bottom. Columns are numbered **1** to **M**, from left to right. You are initially at cell (1, 1) and want to go to cell (**N, M**). From any cell you can move to the cell below it or to the cell right to it. You should never go out of the grid. At any point you should consider all the possibilities of movement with equal probability

Let P\[i\]\[j\] be the probability of visiting cell (i, j). You need to calculate the sum of P\[i\]\[j\] for **1** ≤ **i** ≤ **N**, **1** ≤ **i** ≤ **M**.

As we all know, Tojo really hates probability related problems. He wants you to solve this task

### Input

The first line of the input contains an integer **T** denoting the number of test cases. The description of **T** test cases follows.Only line of each test case has two integer **N** and **M**.

### Output

For each test case, output a single line containing the required answer. Answers within an absolute or relative error of 10-6 will be accepted.

### Constraints

- **1** ≤ **T** ≤ **1000**
- **1** ≤ **N** ≤ **1000**
- **1** ≤ **M** ≤ **1000**

### Example

<pre><b>Input:</b>
2
2 2
1 6

<b>Output:</b>
3.000000
6.000000
</pre>### Explanation

**Example case 1**

Probability matrix P for N=2, M=2 is
1.0 0.5
0.5 1.0
You are at (1, 1) initially. So the probablity of visiting (1, 1) is 1. At (1, 1) you have 2 options, move below to (2, 1) or to right cell (1, 2). Probablity of going to (1, 2) is 0.5. Probability of going to (2, 1) is 0.5. You always end up at (2, 2), so P\[2\]\[2\] is 1. Required sum = 1.0 + 0.5 + 0.5 + 1.0 = 3.0

**Example case 2**

Probability matrix P for N=1, M=6 is
1.0 1.0 1.0 1.0 1.0 1.0
Because at any position there is only one possible next position.