#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
using namespace std;

class Edge
{
public:
    int to, cap, rev;
    Edge(){};
    Edge(int to0, int cap0){to = to0; cap = cap0;}
    Edge(int to0, int cap0, int rev0){to = to0; cap = cap0; rev = rev0;}
};

int maxFlow(const vector<vector<Edge> >& edges0, int source, int sink, vector<vector<Edge> >& edgesOut)
{
    static vector<vector<Edge> > edges;
    static vector<unsigned> index;
    static vector<int> level;
    static int n;

    class Func{
    public:
        static void bfs(int s){
            level.assign(n, -1);
            queue<int> q;
            level[s] = 0;
            q.push(s);
            while(!q.empty()){
                int v = q.front();
                q.pop();
                for(unsigned i=0; i<edges[v].size(); ++i){
                    Edge& e = edges[v][i];
                    if(e.cap > 0 && level[e.to] < 0){
                        level[e.to] = level[v] + 1;
                        q.push(e.to);
                    }
                }
            }
        }
        static int dfs(int s, int t, int f){
            if(s == t)
                return f;
            for(unsigned& i=index[s]; i<edges[s].size(); ++i){
                Edge& e = edges[s][i];
                if(e.cap > 0 && level[s] < level[e.to]){
                    int g = dfs(e.to, t, min(f, e.cap));
                    if(g > 0){
                        e.cap -= g;
                        edges[e.to][e.rev].cap += g;
                        return g;
                    }
                }
            }
            return 0;
        }
    };

    if(source == sink){
        edgesOut = edges;
        return INT_MAX;
    }

    n = edges0.size();
    edges = edges0;

    int ret = 0;
    for(;;){
        Func::bfs(source);
        if(level[sink] < 0){
            edgesOut.swap(edges);
            return ret;
        }
        index.assign(n, 0);
        int f;
        while((f = Func::dfs(source, sink, INT_MAX)) > 0)
            ret += f;
    }
}

const int INF = INT_MAX / 2;

int main()
{
    int k, n, m;
    cin >> k >> n >> m;

    vector<vector<Edge> > edges(n+k+2);
    int source = n + k + 1;
    int sink = 0;
    for(int i=1; i<=k; ++ i){
        edges[source].push_back(Edge(i, INF, edges[i].size()));
        edges[i].push_back(Edge(source, INF, edges[source].size()-1));
    }
    for(int i=0; i<m; ++i){
        int a, b, c;
        cin >> a >> b >> c;
        if(a == 0 || b == 0){
            if(1 <= a + b && a + b <= k){
                cout << "overfuro" << endl;
                return 0;
            }
        }
        edges[a].push_back(Edge(b, c, edges[b].size()));
        edges[b].push_back(Edge(a, c, edges[a].size()-1));
    }

    vector<vector<Edge> > edges2;
    int flow = maxFlow(edges, source, sink, edges2);
    vector<bool> check(n+k+2, false);
    queue<int> q;
    check[source] = true;
    q.push(source);
    while(!q.empty()){
        int pos = q.front();
        q.pop();
        for(const Edge& e : edges2[pos]){
            if(e.cap > 0 && !check[e.to]){
                check[e.to] = true;
                q.push(e.to);
            }
        }
    }

    vector<int> addFlow(n+k+2);
    for(int i=0; i<n+k+2; ++i){
        vector<vector<Edge> > edges3;
        if(check[i])
            addFlow[i] = maxFlow(edges2, source, i, edges3);
        else
            addFlow[i] = maxFlow(edges2, i, sink, edges3);
    }

    int ans = flow;
    for(int i=0; i<n+k+2; ++i){
        for(const Edge& e : edges2[i]){
            if(check[i] ^ check[e.to])
                ans = max(ans, flow + min(addFlow[i], addFlow[e.to]));
        }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3312