module.exports=function(e){var r={};function t(n){if(r[n])return r[n].exports;var o=r[n]={i:n,l:!1,exports:{}};return e[n].call(o.exports,o,o.exports,t),o.l=!0,o.exports}return t.m=e,t.c=r,t.d=function(e,r,n){t.o(e,r)||Object.defineProperty(e,r,{enumerable:!0,get:n})},t.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},t.t=function(e,r){if(1&r&&(e=t(e)),8&r)return e;if(4&r&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(t.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&r&&"string"!=typeof e)for(var o in e)t.d(n,o,function(r){return e[r]}.bind(null,o));return n},t.n=function(e){var r=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(r,"a",r),r},t.o=function(e,r){return Object.prototype.hasOwnProperty.call(e,r)},t.p="",t(t.s=0)}([function(e,r,t){t(1)(t(2).readFileSync("/dev/stdin","UTF-8").split("s"))},function(e,r,t){"use strict";e.exports=function(e){for(var r=0,t=parseInt(e[r++],10),n=new Array(t),o=0;o<t;o++)n[o]=[];for(var u=0;u<t-1;u++){var a=parseInt(e[r++],10),f=parseInt(e[r++],10),i=parseInt(e[r++],10);n[a-1].push([f-1,i]),n[f-1].push([a-1,i])}for(var p=parseInt(e[r++],10),l=parseInt(e[r++],10),s=new Array(t).fill(-1),c=[[l-1,0]];c.length>0;)for(var d=c.pop(),v=n[d[0]].length,y=0;y<v;y++){var b=n[d[0]][y];if(-1==s[b[0]]){var g=d[1]+b[1];s[b[0]]=g,c.push([b[0],g])}}for(var x=0;x<p;x++){var I=parseInt(e[r++],10),j=parseInt(e[r++],10);s[I],s[j]}}},function(e,r){e.exports=require("fs")}]);