**Problem link** : contest

practice

**Difficulty** : Medium

**Pre-requisites** : max flow

**Solution** :

We can construct a flow network from the graph. We can notice that answer of each query would be to apply max flow considering A as source and B as target.

For finding max flow in graph, we can use Edmond Karp, Ford Fulkerson, Dinic’s algorithm etc. Any of them would have worked here.

**Setter’s solution**: link