#include <iostream>
#include <cmath>
using namespace std;
const int MAX_N = 20;
int n;
double dist[MAX_N][MAX_N];
int prev[MAX_N];
double optval = INFINITY;
int optsol[MAX_N];
void solve(int u = 0) {
bool end = true;
for (int v = 0; v < n; ++v) {
if (prev[v] == -1) {
end = false;
prev[v] = u;
solve(v);
prev[v] = -1;
}
}
if (end) {
double length = dist[u][0];
for (int v = u; v != 0; v = prev[v])
length += dist[prev[v]][v];
if (length < optval) {
optval = length;
for (int i = 0; i < n; ++i)
optsol[i] = prev[i];
optsol[0] = u;
}
}
}
int main() {
// get input
cin >> n;
for (int i = 0; i < n; ++i)
for (int j = 0; j < n; ++j)
cin >> dist[i][j];
for (int i = 0; i < n; ++i)
prev[i] = -1;
prev[0] = 0;
solve();
for (int u = optsol[0]; u != 0; u = optsol[u])
cout << u+1 << " <- ";
cout << 1 << " : " << optval << endl;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8Y21hdGg+CnVzaW5nIG5hbWVzcGFjZSBzdGQ7Cgpjb25zdCBpbnQgTUFYX04gPSAyMDsKaW50IG47CmRvdWJsZSBkaXN0W01BWF9OXVtNQVhfTl07CmludCBwcmV2W01BWF9OXTsKCmRvdWJsZSBvcHR2YWwgPSBJTkZJTklUWTsKaW50IG9wdHNvbFtNQVhfTl07Cgp2b2lkIHNvbHZlKGludCB1ID0gMCkgewogIGJvb2wgZW5kID0gdHJ1ZTsKICBmb3IgKGludCB2ID0gMDsgdiA8IG47ICsrdikgewogICAgaWYgKHByZXZbdl0gPT0gLTEpIHsKICAgICAgZW5kID0gZmFsc2U7CiAgICAgIHByZXZbdl0gPSB1OwogICAgICBzb2x2ZSh2KTsKICAgICAgcHJldlt2XSA9IC0xOwogICAgfQogIH0KICBpZiAoZW5kKSB7CiAgICBkb3VibGUgbGVuZ3RoID0gZGlzdFt1XVswXTsKICAgIGZvciAoaW50IHYgPSB1OyB2ICE9IDA7IHYgPSBwcmV2W3ZdKSAKICAgICAgbGVuZ3RoICs9IGRpc3RbcHJldlt2XV1bdl07CiAgICBpZiAobGVuZ3RoIDwgb3B0dmFsKSB7CiAgICAgIG9wdHZhbCA9IGxlbmd0aDsKICAgICAgZm9yIChpbnQgaSA9IDA7IGkgPCBuOyArK2kpCiAgICAgICAgb3B0c29sW2ldID0gcHJldltpXTsKICAgICAgb3B0c29sWzBdID0gdTsKICAgIH0KICB9Cn0KCmludCBtYWluKCkgewogIC8vIGdldCBpbnB1dAogIGNpbiA+PiBuOwogIGZvciAoaW50IGkgPSAwOyBpIDwgbjsgKytpKQogICAgZm9yIChpbnQgaiA9IDA7IGogPCBuOyArK2opCiAgICAgIGNpbiA+PiBkaXN0W2ldW2pdOwoKICBmb3IgKGludCBpID0gMDsgaSA8IG47ICsraSkKICAgIHByZXZbaV0gPSAtMTsKICBwcmV2WzBdID0gMDsKCiAgc29sdmUoKTsKCiAgZm9yIChpbnQgdSA9IG9wdHNvbFswXTsgdSAhPSAwOyB1ID0gb3B0c29sW3VdKSAKICAgIGNvdXQgPDwgdSsxIDw8ICIgPC0gIjsKICBjb3V0IDw8IDEgPDwgIiAgOiAgIiA8PCBvcHR2YWwgPDwgZW5kbDsKfQ==
ICA2CiAgMCA0NzAgNTUwIDQyMCAzMDAgMjAwIAogIDQ3MCAwIDgwMCA5MDAgNzcwIDU2MCAKICA1NTAgODAwIDAgMzMwIDY1MCA3NTAgCiAgNDIwIDkwMCAzMzAgMCA0NTAgNDAwIAogIDMwMCA3NzAgNjUwIDQ1MCAwIDE4MCAKICAyMDAgNTYwIDc1MCA0MDAgMTgwIDAg
6
0 470 550 420 300 200
470 0 800 900 770 560
550 800 0 330 650 750
420 900 330 0 450 400
300 770 650 450 0 180
200 560 750 400 180 0