#include <iostream>#include <string>#include <memory.h>using namespace std;const int MAX = 105;int a, b, n, vis[MAX][MAX], step[MAX*MAX], l, r;string opr[7] = {" ", "fill A", "fill B", "empty A", "empty B", "pour B A", "pour A B"};struct Info{ int ca; int cb; int operation; int pre;}info[MAX*MAX];void solve(int x, int y, int s){ if (vis[x][y]) return ; vis[x][y] = 1; info[r].ca = x; info[r].cb = y; info[r].operation = s; info[r].pre = l; r++;}void output(){ int top,i; top = 0; while(l != 0) { step[top++] = info[l].operation; l = info[l].pre; } for(i = top-1; i >= 0; i--) { cout << opr[step[i]] << endl; } printf("success\n");}void bfs(){ info[0].ca = 0; info[0].cb = 0; vis[0][0] = 1; l = 0; r = 1; while (l != r){ if (info[l].cb == n){ output(); return ; } int tmpa, tmpb; tmpa = a; tmpb = info[l].cb; solve(tmpa, tmpb, 1); tmpa = info[l].ca; tmpb = b; solve(tmpa, tmpb, 2); tmpa = 0; tmpb = info[l].cb; solve(tmpa, tmpb, 3); tmpa = info[l].ca; tmpb = 0; solve(tmpa, tmpb, 4); tmpa = info[l].ca + min(a-info[l].ca, info[l].cb); tmpb = info[l].cb - min(a-info[l].ca, info[l].cb); solve(tmpa, tmpb, 5); tmpa = info[l].ca - min(b-info[l].cb, info[l].ca); tmpb = info[l].cb + min(b-info[l].cb, info[l].ca); solve(tmpa, tmpb, 6); l++; }}int main(){ while (cin >> a >> b >> n){ memset(vis, 0, sizeof(vis)); bfs(); } system("pause");}