module.exports=function(r){var t={};function e(n){if(t[n])return t[n].exports;var u=t[n]={i:n,l:!1,exports:{}};return r[n].call(u.exports,u,u.exports,e),u.l=!0,u.exports}return e.m=r,e.c=t,e.d=function(r,t,n){e.o(r,t)||Object.defineProperty(r,t,{enumerable:!0,get:n})},e.r=function(r){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(r,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(r,"__esModule",{value:!0})},e.t=function(r,t){if(1&t&&(r=e(r)),8&t)return r;if(4&t&&"object"==typeof r&&r&&r.__esModule)return r;var n=Object.create(null);if(e.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:r}),2&t&&"string"!=typeof r)for(var u in r)e.d(n,u,function(t){return r[t]}.bind(null,u));return n},e.n=function(r){var t=r&&r.__esModule?function(){return r.default}:function(){return r};return e.d(t,"a",t),t},e.o=function(r,t){return Object.prototype.hasOwnProperty.call(r,t)},e.p="",e(e.s=0)}([function(r,t,e){e(1)(e(2).readFileSync("/dev/stdin","UTF-8").split("\n"))},function(r,t,e){"use strict";function n(r,t){return function(r){if(Array.isArray(r))return r}(r)||function(r,t){var e=[],n=!0,u=!1,o=void 0;try{for(var i,l=r[Symbol.iterator]();!(n=(i=l.next()).done)&&(e.push(i.value),!t||e.length!==t);n=!0);}catch(r){u=!0,o=r}finally{try{n||null==l.return||l.return()}finally{if(u)throw o}}return e}(r,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance")}()}r.exports=function(r){for(var t=Number(r[0]),e=new Array(t),u=0;u<t;u++)e[u]=[];for(var o=0;o<t-1;o++){var i=n(r[o+1].split(" ").map(function(r){return Number(r)}),3),l=i[0],a=i[1],f=i[2];e[l-1].push({v:a-1,c:f}),e[a-1].push({v:l-1,c:f})}for(var c=n(r[t].split(" ").map(function(r){return Number(r)}),2),s=c[0],v=c[1],p=new Array(t).fill(-1),y=[{v:v-1,sum:0}],d=0;y.length>d;){var m=y[d];d++,p[m.v]=m.sum;var b=!0,h=!1,x=void 0;try{for(var g,S=e[m.v][Symbol.iterator]();!(b=(g=S.next()).done);b=!0){var j=g.value;-1==p[j.v]&&y.push({v:j.v,sum:m.sum+j.c})}}catch(r){h=!0,x=r}finally{try{b||null==S.return||S.return()}finally{if(h)throw x}}}for(var w=0;w<s;w++){var O=n(r[w+t+1].split(" ").map(function(r){return Number(r)}),2),_=O[0],P=O[1],A=p[_-1]+p[P-1];console.log(A)}}},function(r,t){r.exports=require("fs")}]);