#include <bits/stdc++.h>
#include "rail.h"
using namespace std;
#ifndef ONLINE_JUDGE
#define dbg(x) cerr << #x <<" "; print(x); cerr << endl;
#else
#define dbg(x)
#endif
void print(long long t) { cerr << t; }
void print(int t) { cerr << t; }
void print(string t) { cerr << t; }
void print(char t) { cerr << t; }
void print(double t) { cerr << t; }
void print(long double t) { cerr << t; }
void print(unsigned long long t) { cerr << t; }
template <class T, class V> void print(pair <T, V> p);
template <class T> void print(vector <T> v);
template <class T> void print(set <T> v);
template <class T, class V> void print(map <T, V> v);
template <class T> void print(multiset <T> v);
template <class T, class V> void print(T v[], V n) { cerr << "["; for (int i = 0; i < n; i++) { cerr << v[i] << " "; } cerr << "]"; }
template <class T, class V> void print(pair <T, V> p) { cerr << "{"; print(p.first); cerr << ","; print(p.second); cerr << "}"; }
template <class T> void print(vector <T> v) { cerr << "[ "; for (T i : v) { print(i); cerr << " "; } cerr << "]"; }
template <class T> void print(set <T> v) { cerr << "[ "; for (T i : v) { print(i); cerr << " "; } cerr << "]"; }
template <class T> void print(multiset <T> v) { cerr << "[ "; for (T i : v) { print(i); cerr << " "; } cerr << "]"; }
template <class T, class V> void print(map <T, V> v) { cerr << "[ "; for (auto i : v) { print(i); cerr << " "; } cerr << "]"; }
bool used[101];
void findLocation(int n, int first, int location[], int stype[]) {
location[0] = first;
stype[0] = 1;
int mn = 10000001, id;
for (int i = 1; i < n; i++) {
int D = getDistance(0, i);
if(D < mn){
mn = D;
id = i;
}
}
location[id] = first + mn;
stype[id] = 2;
used[0] = used[id] = 1;
for (int i = 1; i < n; i++) {
if (used[i]) continue;
int D1 = getDistance(0, i);
int D2 = getDistance(id, i);
if (D1 == mn + D2) {
stype[i] = 1;
location[i] = location[id] - D2;
}
else {
stype[i] = 2;
location[i] = location[0] + D1;
}
}
}