You are given a keyboard that consists of 26 keys. The keys are arranged sequentially in one row in a certain order. Each key corresponds to a unique lowercase Latin letter.

You have to type the word s on this keyboard. It also consists only of lowercase Latin letters.

To type a word, you need to type all its letters consecutively one by one. To type each letter you must position your hand exactly over the corresponding key and press it.

Moving the hand between the keys takes time which is equal to the absolute value of the difference between positions of these keys (the keys are numbered from left to right). No time is spent on pressing the keys and on placing your hand over the first letter of the word.

For example, consider a keyboard where the letters from 'a' to 'z' are arranged in consecutive alphabetical order. The letters 'h', 'e', 'l' and 'o' then are on the positions 8, 5, 12 and 15, respectively. Therefore, it will take |5 - 8| + |12 - 5| + |12 - 12| + |15 - 12| = 13 units of time to type the word "hello". 

Determine how long it will take to print the word s.

Input

The first line contains an integer t (1 ≤ t ≤ 1000) — the number of test cases.

The next 2t lines contain descriptions of the test cases.

The first line of a description contains a keyboard — a string of length 26, which consists only of lowercase Latin letters. Each of the letters from 'a' to 'z' appears exactly once on the keyboard.

The second line of the description contains the word s. The word has a length from 1 to 50 letters inclusive and consists of lowercase Latin letters.

Output

Print t lines, each line containing the answer to the corresponding test case. The answer to the test case is the minimal time it takes to type the word s on the given keyboard.

Example

Input


5
abcdefghijklmnopqrstuvwxyz
hello
abcdefghijklmnopqrstuvwxyz
i
abcdefghijklmnopqrstuvwxyz
codeforces
qwertyuiopasdfghjklzxcvbnm
qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq
qwertyuiopasdfghjklzxcvbnm
abacaba


Output


13
0
68
0
74
1
abcdefghijklmnopqrstuvwxyz
acsacnkjanscjanjkcanc
 1
abcdefghilkjmnopqrstuvwxyz
abdes

164
 18

/*===============================
Author   :   Shadman Shariar   ||
===============================*/
import java.io.*;
import java.util.*;
//import java.math.BigInteger;
//import java.text.DecimalFormat;
public class Main {
public static Main obj = new Main();
public static int [] dx = {-1, 1, 0, 0, -1, -1, 1, 1};
public static int [] dy = {0, 0, -1, 1, -1, 1, -1, 1};
public static final long mod=(long)(Math.pow(10,9)+7);
//public static FastReader fr = new FastReader();
//public static Scanner input = new Scanner(System.in);
//public static PrintWriter pw = new PrintWriter(System.out);
//public static DecimalFormat df = new DecimalFormat(".000");
//public static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
public static void main (String[]args) throws Exception{Scanner input=new Scanner(System.in);
//===========================================================================================//
//BigInteger bi = new BigInteger("1000");
//StringBuilder sb = new StringBuilder();
//StringBuffer sbf = new StringBuffer();
//StringTokenizer st = new StringTokenizer("string","split");
//Vector vc = new Vector();
//ArrayList<Integer> al= new ArrayList<Integer>();
//LinkedList<Integer> ll= new LinkedList<Integer>();
//Stack <Integer> stk = new Stack <Integer>();
//Queue <Integer> q = new LinkedList<Integer>();
//ArrayDeque<Integer> ad = new ArrayDeque<Integer>();
//PriorityQueue <Integer> pq = new PriorityQueue<Integer>();
//PriorityQueue <Integer> pqr = new PriorityQueue<Integer>(Comparator.reverseOrder());
//HashSet<Integer> hs = new HashSet<Integer>();
//LinkedHashSet<Integer> lhs = new LinkedHashSet<Integer>();
//TreeSet<Integer> ts = new TreeSet<Integer>();
//TreeSet<Integer> tsr = new TreeSet<Integer>(Comparator.reverseOrder());
//Hashtable<Integer,Integer> ht = new Hashtable<Integer,Integer>();
//HashMap<Integer,Integer> hm = new HashMap<Integer,Integer>();
//LinkedHashMap<Integer,Integer> lhm = new LinkedHashMap<Integer,Integer>();
//TreeMap<Integer,Integer> tm = new TreeMap<Integer,Integer>();
//TreeMap<Integer,Integer> tmr = new TreeMap<Integer,Integer>(Comparator.reverseOrder());
//LinkedList<Integer> adj[] = new LinkedList[1000];
//===========================================================================================//

int tc = 1 ;

tc = input.nextInt();

for (int tt = 0; tt < tc; tt++) {
	
String s = input.next();

String st = input.next();

int ans=0;

int [] arr = new int [st.length()];

for (int i = 0; i < st.length(); i++) {
	
	for (int j = 0; j < s.length(); j++) {
		
		if(st.charAt(i)==s.charAt(j)) {
			
			arr[i] = j+1;
			break;
		}
		
	}
	
}

	for (int i = 0; i <st.length()-1; i++) {
		
		ans+=(Math.abs(arr[i]-arr[i+1]));
		
	}
	System.out.println(ans);
}

//===========================================================================================//
      //pw.flush();
      //pw.close();
      input.close();
      System.exit(0);
}
//===========================================================================================//
//----->> Temporary Method Starts Here <<-----//

//----->>  Temporary Method Ends Here  <<-----//
//===========================================================================================//
public static long lcm(long a,long b){return (a/gcd(a,b))*b;}
public static long gcd(long a,long b){if(a==0)return b;return gcd(b%a,a);}
public static long nPr(long n,long r){return factorial(n)/factorial(n-r);}
public static long nCr(long n,long r){return factorial(n)/(factorial(r)*factorial(n-r));}
public static long factorial(long n){return (n==1||n==0)?1:n*factorial(n-1);}
public static long countsubstr(String str){long n=str.length();return n*(n+1)/2;}
public static long fastpower(long a,long b,long n) {long res=1;while(b>0){if((b&1)!=0)
{res=(res*a%n)%n;}a=(a%n*a%n)%n;b=b>>1;}return res;}
public static void subsequences(String s,String ans){if(s.length()==0){ss.
add(ans);return;}subsequences(s.substring(1),ans+s.charAt(0));subsequences
(s.substring(1),ans);}public static List<String>ss=new ArrayList<>();
public static boolean perfectsquare(long x){if(x>=0)
{long sr=(long)(Math.sqrt(x));return((sr*sr)==x);}return false;}
public static boolean perfectcube(long N){int cube;int c=0;for(int i=0;i<=N;i++){cube=i*i*i;
if(cube==N){c=1;break;}else if (cube>N){c=0;break;}}if(c==1)return true;else return false;}
public static boolean[] sieveOfEratosthenes(int n){boolean prime[]=new boolean[n+1];
for (int i = 0; i <= n; i++)prime[i] = true;for (int p = 2; p * p <= n; p++){
if(prime[p]==true){for(int i=p*p;i<=n;i+=p)prime[i]=false;}}prime[1]=false;return prime;}
public static int binarysearch(int arr[],int l,int r,int x) 
{if (r >= l){int mid = l + (r - l) / 2;if (arr[mid]==x)return mid;if(arr[mid]>x)return
binarysearch(arr, l, mid - 1, x);return binarysearch(arr, mid + 1, r, x);}return -1;}
public static void rangeofprime(int a,int b){int i, j, flag;for (i = a; i <= b; i++)
{if (i == 1 || i == 0)continue;flag = 1;for (j = 2; j <= i / 2; ++j) {if (i % j == 0)
{flag = 0;break;}}if (flag == 1)System.out.println(i);}}
public static boolean isprime(long n){if(n<=1)return false;else if(n==2)return true;else if
(n%2==0)return false;for(long i=3;i<=Math.sqrt(n);i+=2){if(n%i==0)return false;}return true;}
//===========================================================================================//
public static class FastReader {
		BufferedReader br;
		StringTokenizer st;
		public FastReader() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}
		String next() {
			while (st == null || !st.hasMoreElements()) {
				try {
					st = new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			}
			return st.nextToken();
		}
		int nextInt() {
			return Integer.parseInt(next());
		}
		long nextLong() {
			return Long.parseLong(next());
		}
		double nextDouble() {
			return Double.parseDouble(next());
		}
		String nextLine() {
			String str = "";
			try {
				str = br.readLine();
			} catch (IOException e) {
				e.printStackTrace();
			}
			return str;
		}
	}
}