| 5 | long long x,n,res; |
| 6 | |
| 7 | int main() |
| 8 | {#include<bits/stdc++.h> |
| 9 | using namespace std; |
| 10 | |
| 11 | int t; |
| 12 | int alphabeta[30]; |
| 13 | char a; |
| 14 | string s; |
| 15 | int ans=0; |
| 16 | |
| 17 | inline int read() |
| 18 | { |
| 19 | int x=0,f=1; |
| 20 | char ch=getchar(); |
| 21 | while(ch<'0'||ch>'9') |
| 22 | { |
| 23 | if(ch=='-') f=-1; |
| 24 | ch=getchar(); |
| 25 | } |
| 26 | while(ch>='0'&&ch<='9') |
| 27 | { |
| 28 | x=x*10+(ch-'0'); |
| 29 | ch=getchar(); |
| 30 | } |
| 31 | return x*f; |
| 32 | } |
| 33 | |
| 34 | int main() |
| 35 | { |
| 36 | |
| 37 | t=read(); |
| 38 | for(int i=1;i<=t;i++) |
| 39 | { |
| 40 | memset(alphabeta,-1,sizeof(alphabeta)); |
| 41 | ans=0; |
| 42 | |
| 43 | for(int j=1;j<=26;j++) |
| 44 | { |
| 45 | cin>>a; |
| 46 | alphabeta[a-'a'+1]=j; |
| 47 | } |
| 48 | cin>>s; |
| 49 | for(int j=0;j<s.length()-1;j++) |
| 50 | { |
| 51 | ans+=abs(alphabeta[s[j+1]-'a'+1]-alphabeta[s[j]-'a'+1]); |
| 52 | } |
| 53 | printf("%d\n",ans); |
| 54 | } |
| 55 | |
| 56 | |
| 57 | return 0; |
| 58 | } |
| 59 | cin>>t; |
| 60 | while(t--) |
| 61 | { |
| 62 | cin>>x>>n; |
| 63 | res=x; |
| 64 | for(long long i=n/4*4+1;i<=n;i++) |