# PROBLEM LINK:

Author: Bhavya Dhingra

Tester: Syed Ali Aatif

Editorialist: Vansh Gupta

# DIFFICULTY:

Simple

# PREREQUISITES:

None

# PROBLEM:

Reading of the 3 balances is given as a, b and c. Here we have to find whether it is possible to make these readings equal, after complete addition/distribution of total N stones among them.

# QUICK EXPLANATION:

We first find how many stones are required to make the 3 readings equal to the maximum value of a, b, and c. If there are sufficient stones, then we check if the remaining number of stones is divisible by 3 or not. “Impossible” is printed if we have insufficient stones or the number of remaining stones is not divisible by 3, as we have to completely use up all the stones. “Possible” is printed in all the other cases.

# EXPLANATION:

As the weight of each stone is equal to 1 unit, so we need not worry about unit conversion.

The minimum number of required stones to make the reading of the 3 balances equal is calculated by subtracting the readings a, b and c each, from the maximum out of them.

If this minimum value required is greater than N (total stones available), then it will be impossible to complete the task.

Now, if the remaining number of stones is 0 (precisely equal to the requirement), or it is divisible by 3 (can be equally divided among the 3 balances), then it is possible to complete the task.

# SOLUTION:

## Setter's Solution

```
#include<bits/stdc++.h>
using namespace std;
#define sync {ios_base ::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);}
#define rep(n) for(int i = 0;i<n;i++)
#define rep1(a,b) for(int i = a;i<b;i++)
#define int long long int
#define mod 1000000007
int n,a,b,c;
void solve()
{
cin>>n>>a>>b>>c;
int minm = 3*max({a,b,c})-(a+b+c);
if(n<minm || (n-minm)%3)
{
cout<<"Impossible";
}
else
{
cout<<"Possible";
}
}
int32_t main()
{
#ifndef ONLINE_JUDGE
freopen("input.txt","r",stdin);
freopen("output.txt","w",stdout);
#endif
sync;
int t = 1;
cin>>t;
while(t--){
solve();
cout<<"\n";
}
return 0;
}
```