# PROBLEM LINK:

Practice

Contest: Division 1

Contest: Division 2

Contest: Division 3

Contest: Division 4

* Author:* S. Manuj Nanthan

*Mradul Bhatnagar*

**Preparer:***Satyam, Jatin Garg*

**Testers:***Nishank Suresh*

**Editorialist:**# DIFFICULTY:

481

# PREREQUISITES:

None

# PROBLEM:

Bob’s current bank balance is W rupees. Each month, rupees X is deposited into it and Y is deducted. How much remains in it after Z months?

# EXPLANATION:

Each month, X rupees is added and Y is deducted, leading to an overall change of X-Y in his balance.

In Z months, this amounts to a total change of Z\times(X-Y).

So, the final balance is W + Z\times(X-Y).

# TIME COMPLEXITY

\mathcal{O}(1) per test case.

# CODE:

## Editorialist's code (Python)

```
for _ in range(int(input())):
w, x, y, z = map(int, input().split())
print(w + z*(x-y))
```