k=int(input())
s=list(input())
n=len(s)
for i in range(n):
if s[i]==s[n-i-1]:
pass
elif s[i]=='?':
s[i]=s[n-i-1]
elif s[n-i-1]=='?':
s[n-i-1]=s[i]
else:
print('IMPOSSIBLE')
exit()
d=set(chr(97+i) for i in range(k) if chr(97+i) not in s)
for i in range(n//2,-1,-1):
if s[n-i-1]==s[i]=='?':
if len(d):
s[n - i - 1] = s[i] = max(d)
d.remove(max(d))
else:
s[n - i - 1] = s[i]='a'
if len(d):
print('IMPOSSIBLE')
else:
print(*s,sep='')
#include <stdio.h>
#include<string.h>
#include<ctype.h>
char s[100010];
int q;
int letter[100010];
int k;
int main()
{
scanf("%d", &k);
scanf("%s", s);
int ss = strlen(s);
int t = ss / 2;
if (ss % 2 == 1) t++;
for (int i = 0; i < t; i++)
{
int j = ss - i - 1;
if (s[i] != s[j])
{
if (isalpha(s[i]) && isalpha(s[j])) {
printf("IMPOSSIBLE");
return 0;
}
else if (s[i] == '?' && s[j] != '?') s[i] = s[j];
else if (s[i] != '?' && s[j] == '?') s[j] = s[i];
}
else if (s[i] == '?' && s[j] == '?') q++;
if (s[i] != '?') letter[s[i] - 'a'] = 1;
if (s[j] != '?') letter[s[j] - 'a'] = 1;
}
int cnt = 0;
for (int i = t - 1; i >= 0; i--)//从中间往前枚举
{
if (s[i] == '?')
{
int id = -1;
for (int i = k - 1; i >= 0; i--)
{
if (!letter[i])//判断是否为?
{
id = i; break;
}
}
if (id == -1) break;
s[i] = id + 'a';
s[ss - i - 1] = id + 'a';
letter[id] = 1;
}
}
for (int i = 0; i < k; i++)
{
if (!letter[i])
{
printf("IMPOSSIBLE");
return 0;
}
}
for (int i = 0; i < t; i++)
{
if (s[i] == '?')
{
s[i] = 'a';
s[ss - i - 1] = 'a';
}
}
printf("%s", s);
return 0;
}
17. Letter Combinations of a Phone Number | 5. Longest Palindromic Substring |
3. Longest Substring Without Repeating Characters | 1312. Minimum Insertion Steps to Make a String Palindrome |
1092. Shortest Common Supersequence | 1044. Longest Duplicate Substring |
1032. Stream of Characters | 987. Vertical Order Traversal of a Binary Tree |
952. Largest Component Size by Common Factor | 212. Word Search II |
174. Dungeon Game | 127. Word Ladder |
123. Best Time to Buy and Sell Stock III | 85. Maximal Rectangle |
84. Largest Rectangle in Histogram | 60. Permutation Sequence |
42. Trapping Rain Water | 32. Longest Valid Parentheses |
Cutting a material | Bubble Sort |
Number of triangles | AND path in a binary tree |
Factorial equations | Removal of vertices |
Happy segments | Cyclic shifts |
Zoos | Build a graph |
Almost correct bracket sequence | Count of integers |