Vasya came up with a password to register for EatForces — a string ss. The password in EatForces should be a string, consisting of lowercase and uppercase Latin letters and digits.

But since EatForces takes care of the security of its users, user passwords must contain at least one digit, at least one uppercase Latin letter and at least one lowercase Latin letter. For example, the passwords "abaCABA12", "Z7q" and "3R24m" are valid, and the passwords "qwerty", "qwerty12345" and "Password" are not.

A substring of string ss is a string x=slsl+1…sl+len−1(1≤l≤|s|,0≤len≤|s|−l+1)x=slsl+1…sl+len−1(1≤l≤|s|,0≤len≤|s|−l+1). lenlen is the length of the substring. Note that the empty string is also considered a substring of ss, it has the length 00.

Vasya's password, however, may come too weak for the security settings of EatForces. He likes his password, so he wants to replace some its substring with another string of the same length in order to satisfy the above conditions. This operation should be performed exactly once, and the chosen string should have the minimal possible length.

Note that the length of ss should not change after the replacement of the substring, and the string itself should contain only lowercase and uppercase Latin letters and digits.

Input

The first line contains a single integer TT (1≤T≤1001≤T≤100) — the number of testcases.

Each of the next TT lines contains the initial password s (3≤|s|≤100)s (3≤|s|≤100), consisting of lowercase and uppercase Latin letters and digits.

Only T=1T=1 is allowed for hacks.

Output

For each testcase print a renewed password, which corresponds to given conditions.

The length of the replaced substring is calculated as following: write down all the changed positions. If there are none, then the length is 00. Otherwise the length is the difference between the first and the last changed position plus one. For example, the length of the changed substring between the passwords "abcdef" →→ "a7cdEf" is 44, because the changed positions are 22 and 55, thus (5−2)+1=4(5−2)+1=4.

It is guaranteed that such a password always exists.

If there are several suitable passwords — output any of them.

Example

Input
2
abcDCE
htQw27
Output
abcD4E
htQw27

Note

In the first example Vasya's password lacks a digit, he replaces substring "C" with "4" and gets password "abcD4E". That means, he changed the substring of length 1.

In the second example Vasya's password is ok from the beginning, and nothing has to be changed. That is the same as replacing the empty substring with another empty substring (length 0).

题解:虽然是A类题,但是还是没能一遍过(哭.....,代码比较low,写给自己体会。

代码如下:

 #include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<string>
#include<cmath>
#include<map>
#include<stack>
#include<vector>
#include<queue>
#include<set>
#include<algorithm>
#define max(a,b) (a>b?a:b)
#define min(a,b) (a<b?a:b)
#define swap(a,b) (a=a+b,b=a-b,a=a-b)
#define maxn 320007
#define N 100000000
#define INF 0x3f3f3f3f
#define mod 1000000009
#define e 2.718281828459045
#define eps 1.0e18
#define PI acos(-1)
#define lowbit(x) (x&(-x))
#define read(x) scanf("%d",&x)
#define put(x) printf("%d\n",x)
#define memset(x,y) memset(x,y,sizeof(x))
#define Debug(x) cout<<x<<" "<<endl
#define lson i << 1,l,m
#define rson i << 1 | 1,m + 1,r
#define ll long long
//std::ios::sync_with_stdio(false);
//cin.tie(NULL);
using namespace std; int d[],x[],s[];
char a[];
int main()
{
int n;
cin>>n;
for(int i=;i<n;i++)
{
memset(a,);
memset(d,);
memset(x,);
memset(s,);
cin>>a;
int l=strlen(a);
int ansd=,ansx=,anss=;
int y=-,yy=-,yyy=-;
for(int j=;j<l;j++)
{
if(a[j]>='a'&&a[j]<='z')
{
y=j;
x[ansx++]=j;
}
if(a[j]>='A'&&a[j]<='Z')
{
yy=j;
d[ansd++]=j;
}
if(a[j]>=''&&a[j]<='')
{
yyy=j;
s[anss++]=j;
}
}
if(y==-)
{
if(ansd>=)
a[d[--ansd]]='a';
else
a[s[--anss]]='a';
}
if(yy==-)
{
if(ansx>=)
a[x[--ansx]]='A';
else
a[s[--anss]]='A';
}
if(yyy==-)
{
if(ansx>=)
a[x[--ansx]]='';
else
a[d[--ansd]]='';
}
cout<<a<<endl;
}
return ;
}

Vasya And Password(CodeForces - 1051A)的更多相关文章

  1. PAT 甲级 1035 Password (20 分)

    1035 Password (20 分) To prepare for PAT, the judge sometimes has to generate random passwords for th ...

  2. 1035 Password (20 分)

    1035 Password (20 分) To prepare for PAT, the judge sometimes has to generate random passwords for th ...

  3. (CodeForces - 5C)Longest Regular Bracket Sequence(dp+栈)(最长连续括号模板)

    (CodeForces - 5C)Longest Regular Bracket Sequence time limit per test:2 seconds memory limit per tes ...

  4. pat 1035 Password(20 分)

    1035 Password(20 分) To prepare for PAT, the judge sometimes has to generate random passwords for the ...

  5. Sorted Adjacent Differences(CodeForces - 1339B)【思维+贪心】

    B - Sorted Adjacent Differences(CodeForces - 1339B) 题目链接 算法 思维+贪心 时间复杂度O(nlogn) 1.这道题的题意主要就是让你对一个数组进 ...

  6. Codeforces 1058 D. Vasya and Triangle(分解因子)

    题目:http://codeforces.com/contest/1058/problem/D 题意:有一个大小为N*M的矩阵内,构造一个三角形,使面积为(n*m)/k.若存在输出三个顶点(整数). ...

  7. Codeforces Round #394 (Div. 2) C. Dasha and Password(简单DP)

    C. Dasha and Password time limit per test 2 seconds memory limit per test 256 megabytes input standa ...

  8. (CodeForces 558C) CodeForces 558C

    题目链接:http://codeforces.com/problemset/problem/558/C 题意:给出n个数,让你通过下面两种操作,把它们转换为同一个数.求最少的操作数. 1.ai = a ...

  9. Vasya and String(尺取法)

    Vasya and String time limit per test 1 second memory limit per test 256 megabytes input standard inp ...

随机推荐

  1. 原生js计时器

    闲来无事,写一个简单的计时器 <!DOCTYPE html> <html lang="en"> <head> <meta charset= ...

  2. JS的深度克隆,利用构造函数原型深度克隆

    我爱撸码,撸码使我感到快乐!大家好,我是Counter.今天来写写,JS中的深度克隆,这个在笔面试中,考的还是比较多的,主要是对象与数组的赋值,如果直接赋值的话,那么得到的是对象或者数组在堆里的地址, ...

  3. Mybatis Generator代码自动生成(实体类、dao层、映射文件)

    写了一段时间增删改查有点厌烦,自己找了下网上的例子鼓捣了下自动生成. 首先得有一个配置文件: generatorConfig.xml <?xml version="1.0" ...

  4. Unity外包 UE4外包 项目案例平台开通通知

    长年承接Unity外包 UE4外包,大家好,本公司团队已将案例上传至专门的案例官网. 欢迎联系我们索取,谢谢! 有项目外包请联系QQ:372900288 索取案例.

  5. ACM:日历本

    题目描述 我们经常需要使用日历,所以需要一个能生成日历的程序. 先要求你写一个程序,只需要输入年份,就能生成正确的日历. 输入 输入包含多组测试数据.每组输入一个整数Y(1800<=Y<= ...

  6. GhostCore核心使用完全指南 - 传送门

    Ghostcore,小坏制作,QQ 532073265,切记不要使用破解版本,后果自负 更新日志 数据表集合 了解模板机制 基本设置 自动备份数据库 自定义字符 扩展的GM命令 NPC脚本(包括幻化. ...

  7. centos用YUM装mysql笔记

    安装的方法,参考:https://blog.csdn.net/jeffleo/article/details/53559712 注意事项: 1.上面教程中,关于设置密码的地方,SQL语句有误,单引号要 ...

  8. yii DbCriteria相关属性常用方法

    $criteria = new CDbCriteria; //函数方式 $criteria->addCondition("id=1"); //查询条件,即where id = ...

  9. spring环境搭建

    1.导入jar包: 2.配置文件 — applicationContext.xml:  添加schema约束,位置:spring-framework-3.2.0.RELEASE—>docs—&g ...

  10. C# linq操作是否延迟对照表

    ·Select - Select选择:延迟 ·Where - Where查询:延迟 ·OrderBy - 按指定表达式对集合正序排序:延迟 ·OrderByDescending - 按指定表达式对集合 ...