#include <iostream>
#include <queue>
#include <vector>
using namespace std;
bool BFS(vector<vector<int>>& Gf, vector<int>& pre, int s, int t, int n)
{
vector<int> visit(n, 0);
for (int i = 0; i < n; i++)
pre[i] = -1;
queue<int> q;
q.push(s);
visit[s] = 1;
while (q.size())
{
int u = q.front();
q.pop();
for (int i = 0; i < n; i++)
{
if (Gf[u][i] != 0 && visit[i] == 0)
{
visit[i] = 1;
pre[i] = u;
q.push(i);
}
}
}
return (visit[t] == 1);
}
int minflow(vector<vector<int>>& Gf, vector<int>& pre, int s, int t, int n)
{
int b = 100;
for (int i = t; i != s; i = pre[i])
b = min(b, Gf[pre[i]][i]);
return b;
}
int maxflow(vector<vector<int>>& adj, int s, int t, int n)
{
vector<vector<int>> Gf(adj);
vector<int> pre(n, -1);
int m = 0;
while (BFS(Gf, pre, s, t, n))
{
int b = minflow(Gf, pre, s, t, n);
m += b;
for (int i = t; i != s; i = pre[i])
{
Gf[pre[i]][i] -= b;
Gf[i][pre[i]] += b;
}
}
return m;
}
int main()
{
int num = 0;
int n;
while (cin >> n)
{
if (n == 0) break;
vector<vector<int>> adj;
adj.resize(n);
for (int i = 0; i < n; i++)
adj[i].resize(n);
int s, t, c;
cin >> s >> t >> c;
s--; t--;
int from, to, capacity;
while (c--)
{
cin >> from >> to >> capacity;
adj[from-1][to-1] += capacity;
adj[to-1][from-1] += capacity;
}
int flow = maxflow(adj, s, t, n);
cout << "Network " << ++num << endl;
cout << "The bandwidth is " << flow << "." << endl;
}
return 0;
}