#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn=1e6+10;
struct node{
	int pos,num;
	bool operator<(const node& a)const{
		return num<a.num;
	}
};
struct node1{
	int pos,num;
	bool operator<(const node1& a)const{
		return pos<a.pos;
	}
};
char s[maxn];
bool vis[maxn]={0};
node p[maxn]={0},p1[maxn]={0};
node1 p2[maxn]={0};
ll ans[maxn]={0};
ll sum[maxn]={0};
int k[100];
int main()
{
	int n;
	scanf("%d %s",&n,s+1);
	int q;
	scanf("%d",&q);
	for(int i=1;i<=q;i++){
		scanf("%d",&k[i]);
	}
	int num=0;
	int now1=0,now2=0;
	for(int i=1;i<=n;i++){
		if(s[i]=='M')num++;
		else if(s[i]=='D'){
			p1[++now1].pos=i;
			p1[now1].num=num;
		}
		else if(s[i]=='C'){
			p[++now2].pos=i;
			p[now2].num=num;
			p2[now2].pos=i;
			p2[now2].num=num;
		}
	}
	for(int i=1;i<=now2;i++){
		sum[i]=sum[i-1]+p[i].num;
	}
	for(int j=1;j<=q;j++)
	{
		ll sum1=0;
	for(int i=1;i<=now1;i++){
		node aa;
		node1 bb;
		aa.num=p1[i].num+1;
		bb.pos=p1[i].pos+k[j];
		int x=lower_bound(p+1,p+now2+1,aa)-p;
		int y=lower_bound(p2+1,p2+now2+1,bb)-p2;
		y--;
		if(x==now2+1)continue;
		sum1+=sum[y]-sum[x-1]-p1[i].num*1ll*(y-x+1);
	}
	ans[j]=sum1;
}
	for(int i=1;i<=q;i++){
		printf("%lld\n",ans[i]);
	}
}
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long ll;
const int INF=1e9;
const long double eps=1e-9;
const double Pi=acos(-1.0);
const int maxn=1e2+10;
struct node{
	int x,y,id;
}a[maxn];
inline bool cmp(const node &lhs,const node &rhs){
	return lhs.x==rhs.x?lhs.y>rhs.y:lhs.x<rhs.x;
}
inline bool Cmp(const node &lhs,const node &rhs){
	return lhs.id<rhs.id;
}
int stk[maxn],ans[maxn],vis[maxn];
double Ans[maxn],slp[maxn];
inline int read(){
	int x=0,flag=1;
	char ch=getchar();
	while(!isdigit(ch) && ch!='-')ch=getchar();
	if(ch=='-')flag=-1,ch=getchar();
	while(isdigit(ch))x=(x<<3)+(x<<1)+ch-'0',ch=getchar();
	return x*flag;
}
inline double Slope(int idx,int idy){
	if(a[idx].x==a[idy].x)return -INF;
	return (a[idx].y-a[idy].y)*1.0/(a[idx].x-a[idy].x);
}
inline double arcle(int idx,int idy){
	if(a[idx].x==a[idy].x){
		if(a[idx].y>a[idy].y)return 0;
		else return Pi;
	}
	if(a[idx].y==a[idy].y){
		if(a[idx].x<a[idy].x)return Pi/2;
		else return 3*Pi/2;
	}
	double slope=-1.0/Slope(idx,idy),arc=atan(slope);
	if(arc<0)arc+=Pi;
	if(a[idx].x<a[idy].x)return arc;
	else return arc+Pi;
}
int main(){
	int i,j,k,m,n,pos;
	n=read();
	for(i=1;i<=n;i++){
		a[i].x=read();a[i].y=read();a[i].id=i;
	}
	sort(a+1,a+n+1,cmp);
	stk[1]=1;stk[2]=2;int top=2;
	for(i=3;i<=n;i++){
		while(top>1 && Slope(stk[top],stk[top-1])>=Slope(i,stk[top]))top--;
		stk[++top]=i;
	}
	for(i=1;i<top;i++)ans[i]=a[stk[i]].id,vis[a[stk[i]].id]=1;pos=top;
	vis[a[1].id]=0;
	reverse(a+1,a+n+1);
	stk[1]=1;stk[2]=2;top=2;
	for(i=3;i<=n;i++){
		if(vis[a[i].id])continue;
		while(top>1 && Slope(stk[top],stk[top-1])>=Slope(i,stk[top]))top--;
		stk[++top]=i;
	}
	for(i=pos;i<pos+top-1;i++)ans[i]=a[stk[i-pos+1]].id;pos=pos+top-2;
	sort(a+1,a+n+1,Cmp);
	ans[0]=ans[pos];ans[pos+1]=ans[1];
	for(i=0;i<=pos;i++)slp[i]=arcle(ans[i+1],ans[i]);
	for(i=1;i<=pos;i++)Ans[ans[i]]=slp[i]-slp[i-1];
	for(i=1;i<=n;i++){
		if(Ans[i]<0)Ans[i]+=2*Pi;
		printf("%.15lf\n",Ans[i]/(2*Pi));
	}
	return 0;
}
