using
System;
using
System.Collections;
using
System.Collections.Generic;
class
GFG
{
static
String decryptStr(String []arr, String str)
{
int
N = str.Length;
int
i = 0, j = N - 1;
while
(Char.IsDigit(str[i]))
i++;
while
(Char.IsDigit(str[j]))
j--;
int
start = Convert.ToInt32(str.Substring(0, i));
int
end = Convert.ToInt32(str.Substring(j+1));
String mid = str.Substring(i, 3);
mid = reverse(mid);
foreach
(String S
in
arr) {
int
upper = 0, sum = 0;
for
(
int
i2 = 0 ; i2 < S.Length ; i2++) {
if
(Char.IsUpper(S[i2]))
upper++;
if
(Char.IsDigit(S[i2]))
sum += ((
int
)S[i2] - (
int
)
'0'
);
}
if
(upper == start && sum == end && S.Substring(S.Length - 3).Equals(mid))
return
S;
}
return
"-1"
;
}
static
String reverse(String input) {
char
[] a = input.ToCharArray();
int
l, r = a.Length - 1;
for
(l = 0 ; l < r ; l++, r--) {
char
temp = a[l];
a[l] = a[r];
a[r] = temp;
}
return
string
.Join(
""
, a);
}
public
static
void
Main(
string
[] args){
String []arr =
new
String[]{
"P@sswORD1"
,
"PASS123word"
};
String str =
"4dro6"
;
Console.WriteLine(decryptStr(arr, str));
}
}