Chef's best friend Jerry gives Chef a string A and wants to know the number of string A that can be obtained from another string BA is made up of unique characters and every character in B can also be found in A. Chef is only allowed to remove string A from string B when it appears as a substring in string B. After one removal, the gap created will be closed and Chef can repeat the process.

Chef wants you to help Jerry to find the answer.

Input

The first line of the input contains T, the number of test cases.

The first line of each test case contains the string A.

The second line of each test case contains the string B.

Note: Please trim trailing whitespaces

Output

For each test case, output a single line consisting of the number of string A that can be obtained from string B as described.

Constraints

  • 1 ≤ T ≤ 20
  • 1 ≤ |A| ≤ 26
  • A is made up of uppercase alphabet only
  • A does not have repeated characters
  • 1 ≤ |B| ≤ 3×105
  • B only contains characters present in A

Example

Input:
2
TIGER
GTIGETIGERRERTIGTTIGERIGERER
HELO
HELHELLOO Output:
5
0

Explanation

Test case 1: 5 TIGERs can be obtained from code B as follows:
GTIGETIGERRERTIGTTIGERIGERER
GTIGETIGERRERTIGTIGERER
GTIGERERTIGTIGERER
GTIGERERTIGER
GTIGERER
GER

主要是运用 string及其使用 的一道题

 # include <bits/stdc++.h>
using namespace std;
int main ()
{
int T; cin>>T;
while(T--)
{
int sum = ;
string a; cin>>a;
string b; cin>>b;
int lena = a.length();
size_t pos = b.find(a,);
cout<<pos<<endl;
for(int i = ;i < b.length();i++)
{
//substr()函数
if(i+>=lena&&b.substr(i+-lena,lena)==a){
++sum;
//erase()函数
b.erase(i+-lena,lena);
i-=lena;
}
}
cout<<sum<<endl;
} return ;
}

最新文章

  1. 如何禁止内部viewPager滑动
  2. [No000081]SVN学习笔记1-服务端搭建
  3. in_array支持第三个参数,强制对数据类型检测
  4. 安卓开发笔记——关于图片的三级缓存策略(内存LruCache+磁盘DiskLruCache+网络Volley)
  5. Zabbix 监控 Nginx 状态
  6. 【leetcode】Subsets
  7. leetcode 146. LRU Cache ----- java
  8. 如何在协作开发安卓项目中打jar包给合作人
  9. 一.CSS工作原理
  10. 11.3 morning
  11. IOS中对于一些控件的抖动效果
  12. [Unity3D]Unity4全新的动画系统Mecanim
  13. push以及pop,shift,unshift
  14. 封装类(Merry May Day to all you who are burried in work ~)---2017-05-01
  15. 安装yum源和gcc编译器遇到的问题
  16. luogu P5320 [BJOI2019]勘破神机
  17. input[type=file]的美化
  18. C++11--时钟和计时器&lt;chrono&gt;
  19. Spring访问数据库(方式上跟HQL类似,每行记录映射一个实体类)
  20. 【SPL标准库专题(9)】 Datastructures:SplObjectStorage

热门文章

  1. js中各种距离clientWidth
  2. linux下查找字符串
  3. Android基础Activity篇——Intent
  4. C++学生信息处理
  5. Java—数组和方法
  6. sqlalchemy使用tip
  7. 在sql中如何把一列的值拆分成多列
  8. ASP.NET Core - 初期准备
  9. 经典的hash函数
  10. BestCoder Round #91 1001 Lotus and Characters