#include<iostream>
#include<cmath>
#include<cstring>
#include<queue>
using namespace std;
const int N = 10010;
typedef pair<int, int> pll;
priority_queue < pll, vector <pll>, greater<pll>> heap;
int g[N][N], dist[N]; bool str[N];
int n; int idx, en[N], e[N], w[N], h[N];
void add(int a, int b, int c)
{
e[idx] = b; w[b] = c; en[idx] = h[a]; h[a] = idx++;
}
int spfa()
{
dist[1] = 0;
queue<int>q;
q.push(1);
str[1] = true;
while (q.size())
{
int t = q.front();
q.pop();
for (int i = h[t]; i != -1; i = en[i])
{
int j = e[i];
if(dist[j]>dist[t]+w[i])
{
dist[j] = min(dist[j], dist[t] + w[j]);
if(!str[j])
{
str[j] = true;
q.push(dist[j]);
}
}
}
}
if(dist[n] != 0x3f)return dist[n];
else return -1;
}
int main()
{
memset(g, 0x3f, sizeof g);
}