#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
using namespace std;

int n, k, m;
set<int> t;

void ck(int* b) {
		int s = 0;

		for (int i = 0; i < k; i++) {
			if (b[i] > 9)
				s = s * 100 + b[i];
			else
				s = s * 10 + b[i];
		}

		if (t.find(s) == t.end()) {
			t.insert(s);
			m++;
		}
}

int main()
{
	cin >> n >> k;

	while (n > 0 || k > 0) {
		vector<int> a(n);

		for (int i = 0; i < n; i++)
			cin >> a[i];

		m = 0;
		int i = (1 << k) - 1;
		t.clear();

		while (i < (1 << n)) {
			vector<int> b;
			for (int j = 0; j < n; j++) {
				if((1 << j) & i)
					b.push_back(j);
			}

			do {
				vector<int> c;
				for (int i = 0; i < k; i++)
					c.push_back(a[b[i]]);

				ck(&c[0]);
			} while (next_permutation(b.begin(), b.end()));

			int x = i & -i, y = i + x;
			i = ((i & ~y) / x >> 1) | y;
		}

		cout << m << endl;

		cin >> n >> k;
	}

	return 0;
}

#include<iostream>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<vector>
#include<string>
#include<stack>
#include<queue>
#include<deque>
#include<set>
#include<map>
#include<algorithm>
#include<functional>
#include<utility>
#include<cmath>
#include<ctime>
#include<complex>

using namespace std;

#define REP(i,s,e) for(int i=int(s);i<=int(e);i++)
#define rep(i,n) for(int i=0;i<int(n);i++)

int f(int n){
	if(n==0) return 1;
	else return 10*f(n-1);
}

int main(){

	int n,k;
	while(1){

		cin >> n >> k;
		if(n==0 && k==0) break;

		vector<int>card(n);
		rep(i,n) cin >> card[i];

		if(k==2){
			vector<int>u;
			rep(i,n){
				rep(j,n){
				  if(i!=j){
					  vector<int>v;
					  if(card[i]/10!=0) v.push_back(card[i]/10);
					                    v.push_back(card[i]%10);
					  if(card[j]/10!=0) v.push_back(card[j]/10);
										v.push_back(card[j]%10);

					  int s=v.size(); int p=0;
					  rep(i,s) p+=v[i]*f(s-1-i);
					  u.push_back(p);
					  v.clear();
				   }
				}
			}

			sort(u.begin(),u.end());
			vector<int>::iterator it=unique(u.begin(),u.end());
			u.erase(it,u.end());

			cout << u.size() << endl;

			u.clear();
		}

		if(k==3){
			vector<int>u;
			rep(i,n){
				rep(j,n){
					rep(k,n){
				  if(i!=j && i!=k && j!=k){
					  vector<int>v;
					  if(card[i]/10!=0) v.push_back(card[i]/10);
					                    v.push_back(card[i]%10);
					  if(card[j]/10!=0) v.push_back(card[j]/10);
										v.push_back(card[j]%10);
					  if(card[k]/10!=0) v.push_back(card[k]/10);
										v.push_back(card[k]%10);

					  int s=v.size(); int p=0;
					  rep(i,s) p+=v[i]*f(s-1-i);
					  u.push_back(p);
					  v.clear();
				   }
				}
			}
		}
			sort(u.begin(),u.end());
			vector<int>::iterator it=unique(u.begin(),u.end());
			u.erase(it,u.end());

			cout << u.size() << endl;

			u.clear();
		}

		if(k==4){
			vector<int>u;
			rep(i,n){
				rep(j,n){
					rep(k,n){
						rep(l,n){
				  if(i!=j && i!=k && i!=l && j!=k && j!=l && k!=l){
					  vector<int>v;
					  if(card[i]/10!=0) v.push_back(card[i]/10);
					                    v.push_back(card[i]%10);
					  if(card[j]/10!=0) v.push_back(card[j]/10);
										v.push_back(card[j]%10);
					  if(card[k]/10!=0) v.push_back(card[k]/10);
										v.push_back(card[k]%10);
					  if(card[l]/10!=0) v.push_back(card[l]/10);
										v.push_back(card[l]%10);

					  int s=v.size(); int p=0;
					  rep(i,s) p+=v[i]*f(s-1-i);
					  u.push_back(p);
					  v.clear();
				   }
				}
			}
		}
	}
			sort(u.begin(),u.end());
			vector<int>::iterator it=unique(u.begin(),u.end());
			u.erase(it,u.end());

			cout << u.size() << endl;

			u.clear();
		}

	}

	return 0;
}


		#include <bits/stdc++.h>
		using namespace std;
		typedef long long ll;
		#define PI 3.14159265358979
		#define EPS 1e-8
		#define mod  998244353
		#define fi first
		#define se second
		#define mp make_pair
		#define pb push_back
		#define endl "\n"

		const ll INF=1e15;
		const int N=2e5+50;

		long long binpow(long long a, long long b, long long m) {
			a %= m;
			long long res = 1;
			while (b > 0) {
				if (b & 1)
					res = res * a % m;
				a = a * a % m;
				b >>= 1;
			}
			return res;
		}

		ll modinverse(ll a,ll m)
		{
			return binpow(a,m-2,m);
		}

		int main()
		{
			ios_base::sync_with_stdio(false);
			cin.tie(NULL);cout.tie(0);

			ll n;
			cin>>n;
			stack<ll> st[1005];
			for(ll i=1;i<=n;i++)
			{
				vector<ll> v;
				for(ll j=1;j<n;j++)
				{
					ll val;cin>>val;
					v.pb(val);
				}

				reverse(v.begin(),v.end());

				for(ll j=0;j+1<n;j++)
				{
					st[i].push(v[j]);
				}
			}

			ll cnt=0;
			ll c1=0;
			while(c1<((n*(n-1))/2))
			{
				ll c=0;
				cnt++;
				vector<ll> vis(1005,0);
				for(ll i=1;i<=n;i++)
				{
					if(!st[i].empty() && !vis[i])
					{
						ll j=st[i].top();
						if(!st[j].empty() && st[j].top()==i && !vis[j])
						{
							//cout<<i<<" "<<j<<endl;
							st[i].pop();
							st[j].pop();
							c=1;
							c1++;
							vis[i]=vis[j]=1;
						}
					}
				}
				if(!c)
				{
					cout<<-1;
					exit(0);
				}
			}
			cout<<cnt;
		}

#include<bits/stdc++.h>
using namespace std;
vector<int>e[1500001];
int dp[1500001];
int vis[1500001];
int dfs(int u)
{
	if(vis[u]==1){printf("-1");exit(0);}
	if(dp[u]) return dp[u];
	vis[u]=1;
	int ans=1;
	for(int i=0;i<e[u].size();i++)
	{
		//printf("%d::%d %d\n",u,e[u][i],dfs(e[u][i])+1);
		ans=max(ans,dfs(e[u][i])+1);
	}
	vis[u]=0;
	return dp[u]=ans;
}
int main()
{
	int n;
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		int pre=0;
		for(int j=1;j<n;j++)
		{
			int x;
			scanf("%d",&x);
			int now=min(i,x)*n+max(i,x);
			e[pre].push_back(now);
			pre=now;
		}
	}
	int ans=dfs(0);
	printf("%d",ans-1);
	return 0;
}


#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(v) v.begin(),v.end()
#define len(x) (ll)(x).length()
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
const int INF=1e9;
const int di[] = {-1,0,1,0};
const int dj[] = {0,-1,0,1};

int main(){
  double n;
  cin>>n;
  vector<vector<double>> d(n,vector<double>(2));
  rep(i,n)rep(j,2) cin>>d[i][j];
  vector<int> t(n);
  rep(i,n) t[i]=i;
  double sum=0;
  int cnt=0;
  do{
    for(int i=1;i<n;i++){
      sum+=sqrt((d[t[i]][0]-d[t[i-1]][0])*(d[t[i]][0]-d[t[i-1]][0])+(d[t[i]][1]-d[t[i-1]][1])*(d[t[i]][1]-d[t[i-1]][1]));
    }
    cnt++;
  }while(next_permutation(all(t)));
  printf("%.10f\n",sum/cnt);
}

//算数的な問題

#include <bits/stdc++.h>
#define rep(i,N) for (int i = 0; i < (N); ++i)
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int inf{int(1e9)};

int f(int n){
  if (n == 0) return 1;
  else return n * f(n - 1);
}

int main(void){
  int N;
  cin >> N;
  vector <int> x(N), y(N);
  rep(i,N) cin >> x[i] >> y[i];
  //ラムダ式
  //点iと点jの距離
  auto dist = [&](int i, int j){
    double dx = x[i] - x[j];
    double dy = y[i] - y[j];
    return sqrt(dx * dx + dy * dy);
  };

  //順列を使わない方法
  double len = 0;
  rep(i,N)rep(j,i){
    len += dist(i,j);
  }
  double ans = (len * 2) / N;

  //順列を使う方法
  // vector <int> p(N);
  // rep(i,N) p[i] = i;
  // double len = 0;  //長さ
  // int cnt = 0;
  // do {
  //   rep(i,N-1){
  //     len += dist(p[i], p[i + 1]);
  //   }
  //   cnt ++;
  // } while (next_permutation(all(p)));
  // double ans = len/cnt;
  cout << fixed << setprecision(10) << ans << endl;
  return 0;
}


#include <bits/stdc++.h>
#define rep(i, n) for(long long int i = 0; i < n; i++)
#define _rep(i, m, n) for(long long int i = m; i < n; i++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const ll mod = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

ll gcd(ll A, ll B){
    if(B == 0)return A;
    return gcd(B, A % B);
}
ll lcm(ll A, ll B){
    return A * B / gcd(A, B);
}
using Graph = vector<vector<int>>;
Graph G;

int main(){
    int n; cin >> n;
    ll x; cin >> x;
    vector<ll> a(n);
    rep(i, n) cin >> a[i];

    ll ans = 0;
    _rep(i, 1, n){
        if(a[i - 1] > x){
            ans += a[i - 1] - x;
            ans += a[i];
            a[i] = 0;
        }else if(a[i - 1] + a[i] > x){
            ans += (a[i - 1] + a[i] - x);
            a[i] = x - a[i - 1];
        }
    }
    cout << ans << endl;
}

// This template belongs to Juan Carlo Vieri

/*   ____   __
    /  _/  |  |    __         __
 __|  |__  |  |   /_/        |  |
|__    __| |  |   __    ____ |  | __   ___   _  ___
   |  |    |  |  |  |  /  _/ |  |/ /  / _ \ | |/ _/
   |  |    |  |  |  | |  |_  |     \ |  __/ |   /
   |__|    |__|  |__|  \___\ |__|\__\ \___\ |__|
*/

#include <bits/stdc++.h>
using namespace std;

typedef int_fast64_t ll;
typedef long double ld;
typedef int_fast64_t intt;
typedef int_fast32_t tmp_m;
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#define from(x, y, arr) (arr[y] - ((x > 0) ? (arr[x - 1]) : (0)))
#define min(a, b) (a > b ? b : a)
#define max(a, b) (a <  b ? b : a)
#define puts(x) cout << x << endl
#define deb(x) cout << #x << ' ' << x << endl
#define rep(i, cmp1, cmp2) for (tmp_m i = (tmp_m)cmp1; i < (tmp_m)cmp2; ++i)
#define repp(i, cmp1, cmp2) for (tmp_m i = (tmp_m)cmp1; i >= (tmp_m)cmp2; --i)
#define pb push_back
#define st stack
#define pa pair
#define vc vector
#define qu queue
#define pq priority_queue
#define fr first
#define sc second
#define mp map
const ld pi = acos(-1.0);
const intt mod = 1e9 + 7;

struct pr {
  intt x;
  intt y;
  intt dst;
  pr() {}
  pr(intt x, intt y, intt dst) : x(x), y(y), dst(dst) {}
  inline bool operator<(const pr& cmp2) const {
    if (dst != cmp2.dst) return dst < cmp2.dst;
    if (x != cmp2.x) return x < cmp2.x;
    return y < cmp2.y;
  }
  inline bool operator==(const pr& cmp2) const {
    return (cmp2.dst == dst) && (cmp2.x == x) && (cmp2.y == y);
  }
  inline bool operator>(const pr& cmp2) const {
    if (dst != cmp2.dst) return dst > cmp2.dst;
    if (x != cmp2.x) return x > cmp2.x;
    return y > cmp2.y;
  }
};

struct point {
  intt x;
  intt y;
  point() {}
  point(intt x, intt y) : x(x), y(y) {}
  inline bool operator<(const point& cmp2) const {
    if (cmp2.x != x) return cmp2.x < x;
    return cmp2.y < y;
  }
  inline bool operator==(const point& cmp2) const {
    return (cmp2.x == x) && (cmp2.y == y);
  }
  inline bool operator>(const point& cmp2) const {
    if (cmp2.x != x) return cmp2.x > x;
    return cmp2.y > y;
  }
};

namespace std {

template<typename T>
struct hash<vector<T> > {
  size_t operator()(const vector<T>& k) const {
    size_t ret = 0xf3ee477d;
    for (size_t i = 0; i != k.size(); ++ i)
      ret ^= hash(hash(k[i]) + i);
    return ret;
  }
};

template<>
struct hash<pr>{
  size_t operator()(const pr& cmp1) const {
    return (hash<intt>()(cmp1.x)) ^ (hash<intt>()(cmp1.y)) ^
           (hash<intt>()(cmp1.dst));
  }
};

template<>
struct hash<point>{
  size_t operator()(const point& cmp1) const {
    return (hash<intt>()(cmp1.x)) ^ (hash<intt>()(cmp1.y));
  }
};
}

inline bool spoint(const point& cmp1, const point& cmp2) {
  // swap(cmp1, cmp2);
  if (cmp1.x != cmp2.x) return cmp1.x < cmp2.x;
  return cmp1.y < cmp2.y;
}

inline bool spr(const pr& cmp1, const pr& cmp2) {
  // swap(cmp1, cmp2);
  if (cmp1.dst != cmp2.dst) return cmp1.dst < cmp2.dst;
  if (cmp1.x != cmp2.x) return cmp1.x < cmp2.x;
  return cmp1.y < cmp2.y;
}

void sub() {

}

void solve() {
  // intt t; cin >> t;
  // while (t--) sub();
  intt n;
  cin >> n;
  vc<intt> arr(n);
  intt nol = 0;
  intt neg = 0;
  rep(i, 0, n){
    cin >> arr[i];
    if(arr[i] == 0)nol = 1;
    if(arr[i] < 0)++neg;;
  }
  if(neg % 2 == 0 || nol){
    intt ans = 0;
    rep(i, 0, n){
      ans += abs(arr[i]);
    }
    cout << ans << endl;
    return;
  } else{
    rep(i, 0, n){
      arr[i] = abs(arr[i]);
    }
    sort(arr.begin(), arr.end());
    intt ans = -(arr[0]);
    rep( i, 1, n){
      ans += arr[i];
    }
    cout << ans << endl;
  }
}

void init() {
  // remove if interactive
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  srand(time(0));
  // memset(dp, -1, sizeof dp);
}

int main() {
  init();
  solve();
  return 0;
}


#include <iostream>
using namespace std;

int main()
{
    string w;
    cin >> w;
    int c = 0;
    if (w == "RRR")
    {
        c = 3;
    }
    else if (w== "RRS" || w == "SRR")
    {
        c= 2;
    }
    else if (w == "SRS" || w == "RSR" || w == "SSR" || w == "RSS")
    {
        c = 1;
    }

    cout << c << endl;

    return 0;
}

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
    string s;
    cin>>s;
    int ans = 0;
    int ma = INT_MIN;
    for(int i=0;i<s.size();i++) {
        if(s[i] == 'R') {
            ans++;
        }
        else {
            ma = max(ma, ans);
            ans = 0;
        }
    }
     ma = max(ma, ans);

    cout<<ma<<endl;
}


#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <math.h>
#include <cstdlib>
#include <iomanip>
#define rep(i,x) for(ll i=0;i<x;i++)
#define all(a) (a).begin(),(a).end()
using namespace std;
using ld = long double;
using ll = long long;
const ll INF = 10010010010;
typedef pair<ll, ll> P;
using graph = vector<vector<ll>>;
const ll mod = 1000000007;
ll gcd(ll a, ll b) {//a>b
    if (a < b)swap(a, b);
    if (a % b == 0) return b;
    else return gcd(b, a % b);
}/*フィボナッチテンプレ
ll memo[50];
ll fibo(ll n) {
    if (memo[n] != 0)return memo[n];
    if (n <= 1)return memo[n] = n;
    else return memo[n] = fibo(n - 1) + fibo(n - 2);
}
*/
bool isp(ll n) {
    bool res = true;
    for (ll i = 2; i * i <= n; i++) {
        if (n % i == 0) {
            res = false;
            break;
        }
    }
    return res;
}

int main() {
  ll N;
  cin >> N;
  if(N == 1)cout << "Hello World" << endl;
  else{
    ll a,b;
    cin >> a >> b;
    cout << a + b << endl;
  }
}

#include<bits/stdc++.h>
using namespace std;
#define FOR(i,a,b)  for(int i=(a),i##formax=(b);i< i##formax;i++)
#define FORR(i,a,b) for(int i=(a),i##formin=(b);i>=i##formin;i--)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define pcnt __builtin_popcount
#define sz(x) (int)(x).size()
#define maxs(x,y) x=max((x),(y))
#define mins(x,y) x=min((x),(y))
#define show(x) cout<<#x<<" = "<<(x)<<endl;
#define all(a) ((a).begin()),((a).end())
#define each(i,c) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();i++)
#define bit(n) (1LL<<(n))
typedef long long ll;
typedef __int128_t lll;
template<class T>using V=vector<T>;
template<class T>using VV=V<V<T>>;
template<class T,class Y>using P=pair<T,Y>;
template<class T,class Y>ostream& operator<<(ostream&o,P<T,Y>&p){return o<<"("<<p.fi<<","<<p.se<<")";}
template<class T>ostream& operator<<(ostream&o,V<T>&v){for(T&t:v)o<<t<<",";return o;}
template<class T>void uniq(V<T>&v){sort(all(v));v.erase(unique(all(v)), v.end());}
template<class A,size_t N,class T>void Fill(A(&a)[N],const T&v){fill((T*)a,(T*)(a+N),v);}

const int MOD = 1e9+7; //998244353;

lll gcd(lll a,lll b,lll&x,lll&y){if(!b){x=1;y=0;return a;}lll d=gcd(b,a%b,y,x);y-=a/b*x;return d;}
ll modInv(ll a,ll m=MOD){lll x,y;gcd(a,m,x,y);return(x%m+m)%m;}
ll modPow(lll a,lll n,ll m=MOD){lll p=1;for(;n;n>>=1,a=a*a%m)if(n&1)p=p*a%m;return p;}
//V<ll>Fac,Rac;void setF(int n,int m=MOD){Fac=Rac=V<ll>(++n);Fac[0]=1;FOR(i,1,n)Fac[i]=Fac[i-1]*i%m;Rac[n-1]=modInv(Fac[n-1],m);FORR(i,n-1,1)Rac[i-1]=Rac[i]*i%m;}
//ll comb(int a,int b,int m=MOD){return a<b||b<0?0:Fac[a]*Rac[b]%m*Rac[a-b]%m;}

const int IINF = 1e9+6;
const ll LINF = 1e18;
const int N = 4e5;
int t, n;
ll a[200];
string s;
int f(){
  cin >> n;
  FOR(i, 0, n) cin >> a[i];
  cin >> s;
  V<ll> v;
  FORR(i, n-1, 0){
    ll e = a[i];
    for(ll l:v) mins(e, e^l);
    if(!e) continue;
    if(s[i]-'0'){
      return 1;
    }else{
      v.pb(e);
    }
  }
  return 0;
}
main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> t;
  FOR(_, 0, t) cout << f() << endl;
}


#include<bits/stdc++.h>
//g++ -std=c++11

using namespace std;
typedef long long ll;

#define rep(i,n) for (long long i = 0; i < (n); ++i)
#define DIV 1000000007 //10^9+7

int main(){
	ll N;
	cin >> N;
	vector<ll> A(N);
	rep(i, N) cin >> A[i];

	set<ll> S;
	map<ll, ll> M;
	rep(i, N) {
		set<ll>::iterator it = S.lower_bound(A[i]);
		if(S.size() == 0 || it == S.begin()) {
			S.insert(A[i]);
			M[A[i]]++;
		} else {
			it--;
			M[*it]--;
			if(M[*it] == 0) {
				M.erase(*it);
				S.erase(*it);
			}
			S.insert(A[i]);
			M[A[i]]++;
		}
	}

	ll ans = 0;
	for(pair<ll, ll> item: M) {
		ans += item.second;
	}
	cout << ans  << endl;

}

#include <iostream>
#include <iomanip>
#include <algorithm>
#include <bitset>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <cmath>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <stack>

using namespace std;

#define int long long
#define ll long long
#define double long double
#define pii pair<int, int>
#define vec vector
#define u_map unordered_map
#define u_set unordered_set
#define str string
#define all(el) el.begin(), el.end()
#define allr(el) el.rbegin(), el.rend()
#define sz(el) (int)el.size()
#define f first
#define s second
#define pb push_back
#define in insert
#define mp make_pair
#define endl "\n"
#define forn(i, n) for (int i = 0; i < n; ++i)

inline int maxi(int &a, int b) { if (b > a) { a = b; return 1; } return 0; }

inline int mini(int &a, int b) { if (b < a) { a = b; return 1; } return 0; }

inline int maxi(double &a, double b) { if (b > a) { a = b; return 1; } return 0; }

inline int mini(double &a, double b) { if (b < a) { a = b; return 1; } return 0; }

int bin_pow(int x, int p) {
    if (p < 0) {
        return 0;
    }
    if (p == 0) {
        return 1;
    }
    if (p % 2 == 0) {
        int ans = bin_pow(x, p / 2);
        return ans * ans;
    }
    return x * bin_pow(x, p - 1);
}

int gcd(int a, int b) {
    if (!b) {
        return a;
    }
    return gcd(b, a % b);
}

signed main() {

    int n;
    cin >> n;
    multiset<int> hv;
    int ans = 0;
    for (int i = 0; i < n; i++) {
        int x;
        cin >> x;
        auto pos = hv.upper_bound(-x);
        if (pos == hv.end()) {
            ans++;
        } else {
            hv.erase(pos);
        }
        hv.in(-x);
    }
    cout << ans;

    return 0;
}


#include<bits/stdc++.h>
#define mems(a,x) memset(a,x,sizeof(a))
#define first fi
#define second se
using namespace std;
typedef long long ll;
const int mod=1e9+7,N=105;
const double eps=1e-8,pi=3.1415926535898;
ll inv(ll x){return x==1?x:(mod-mod/x)*inv(mod%x)%mod;}
ll inv(ll x,ll mod){return x==1?x:(mod-mod/x)*inv(mod%x,mod)%mod;}
ll qpow(ll a,ll n){ll ans=1;while(n){if(n&1) ans=ans*a%mod;a=a*a%mod;n>>=1;}return ans;}
ll mul(ll a,ll b){ll ans=0;while(b){if(b&1) ans=(ans+a)%mod;a=(a+a)%mod;b>>=1;};return ans;}
ll qpow(ll a,ll n,ll mod){ll ans=1;while(n){if(n&1) ans=ans*a%mod;a=a*a%mod;n>>=1;}return ans;}
ll mul(ll a,ll b,ll mod){ll ans=0;while(b){if(b&1) ans=(ans+a)%mod;a=(a+a)%mod;b>>=1;};return ans;}
struct vec
{
    double x,y;
    int id;
    vec(double x=0,double y=0):x(x),y(y){}
    vec operator+(const vec&o)const{ return vec(x+o.x,y+o.y);}
    vec operator-(const vec&o)const{ return vec(x-o.x,y-o.y);}
    double operator*(const vec&o)const{ return x*o.x+y*o.y;}
    double operator^(const vec&o)const{ return x*o.y-y*o.x;}
    vec operator/(const double&o)const{ return vec(x/o,y/o);}
    vec operator*(const double&o)const{ return vec(x*o,y*o);}
    void sc(){scanf("%lf%lf",&x,&y);}
    double len(){return sqrt(x*x+y*y);}
}a[N],s[N];
int n,top;
bool cmp(vec x,vec y)
{
    double k1=atan2(x.y-a[1].y,x.x-a[1].x),k2=atan2(y.y-a[1].y,y.x-a[1].x);
    if(fabs(k1-k2)<eps) return x.x<y.x;
    return k1<k2;
}
double ans[N];
int main()
{
    scanf("%d",&n);
    for(int i=1;i<=n;i++) a[i].sc(),a[i].id=i;
    for(int i=1;i<=n;i++)
        if(a[i].y<a[1].y||a[i].y==a[1].y&&a[i].x<a[1].x)
        swap(a[i],a[1]);
    sort(a+2,a+1+n,cmp);
    for(int i=1;i<=n;i++)
    {
        while(top>=2&&((s[top-1]-a[i])^(s[top]-a[i]))<=0) top--;
        s[++top]=a[i];
    }
    if(top==1) ans[s[1].id]=1;
    else if(top==2) ans[s[1].id]=ans[s[2].id]=0.5;
    else
        for(int i=1;i<=top;i++)
        {
            vec l,r;
            if(i==1) l=s[top];
            else l=s[i-1];
            if(i==top) r=s[1];
            else r=s[i+1];
            double res=(r-s[i])*(l-s[i]);
            res/=(r-s[i]).len()*(l-s[i]).len();
            res=pi-acos(res);
            res/=2*pi;
            ans[s[i].id]=res;
        }
    for(int i=1;i<=n;i++)
        printf("%.10f\n",ans[i]);
}

#include<iostream>
#include<complex>
#include<math.h>
#include<algorithm>
using namespace std;
int n,i,j;
double x[100],y[100],a[101],Ans[100];
complex<double>z[100];
int main()
{
  cin >> n;
  for(i=0;i<n;i++){
    cin >> x[i] >> y[i];
    z[i]=complex<double>(x[i],y[i]);
  }
    for(i=0;i<n;i++){
      for(j=0;j<n;j++){
        a[j]=fmod(arg(z[j]-z[i])+2*M_PI,2*M_PI);
      }
      sort(a,a+n);
      a[n]=a[1]+2*M_PI;
      for(j=1;j<n;j++){
        if(a[j+1]-a[j]>=M_PI){Ans[i]=(a[j+1]-a[j]-M_PI)/2/M_PI;
                             }
      }
      cout << Ans[i] << endl;
    }
}


#include <stdio.h>

int main(){

    long long n, sum = 0;
    scanf("%lld", &n);
    for(long long i = 1 ; i <= n ; i++){
    	if(i%3 != 0 && i%5 != 0){
    		sum+=i;
		}
	}
    printf("%lld\n", sum);

    return 0;
}

#define rep(i,n) for (int i=0;i<n;i++)
#include <vector>
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;

int main(){
  string s;
  cin >> s;
  int co=0;
  rep(i,3){
    if(s.at(i)=='R') co++;
  }

  if(co==3)
    cout << 3 << endl;
  else if(co==2 && s.at(1)!='S')
    cout << 2 << endl;
  else if(co==0)
    cout << 0 << endl;
  else
    cout << 1 << endl;

}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll,ll> pll;
const ll mod=1e9+7;
//const ll mod=998244353;
const ll inf=5e18;

int main() {
  ll a;
  cin >> a;
  if(a<1200) cout << "ABC" << endl;
  else if(a<2800) cout << "ARC" << endl;
  else cout << "AGC" << endl;
}

#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long;

// i桁目まで見て j枚多く払う時(0 or 1)
ll dp[1000100][2];

int main() {
  string s;
  cin >> s;

  s = '0' + s;
  int n = (int)s.size();
  memset(dp, 0, sizeof(dp));
  dp[0][1] = 1;

  for (int i = 1; i < n; i++) {
    int current = s[i] - '0';
    dp[i][0] = min(dp[i - 1][0] + current, dp[i - 1][1] + (10 - current));
    dp[i][1] = min(dp[i - 1][0] + current + 1, dp[i - 1][1] + (9 - current));
  }
  cout << dp[n - 1][0] << '\n';
}


#include <bits/stdc++.h>

using namespace std;
using ll=long long;
#define rep(i,n)  for(ll i=0;i<n;++i)
#define all_map(itr,mp) for(auto itr=mp.begin();itr!=mp.end();itr++)
#define ALL(a) (a).begin(),(a).end()

#define MOD 1000000007

int main(){
    ll h, w, k;
    cin >> h >> w >> k;

    ll dp[110][10] = {};
    dp[0][0] = 1;

    rep(i, h)rep(j, w)rep(k,(1<<(w-1))){
        bool isok = true;
        rep(l, w-2)if(k & (1<<l) && k & (1<<(l+1))){
            isok = false;
            break;
        }
        if(isok){
            if(j > 0 && (1<<(j-1) & k)){
                dp[i+1][j-1] += dp[i][j];
                dp[i+1][j-1] %= MOD;
            }
            else if(j < w-1 && (1<<j) & k){
                dp[i+1][j+1] += dp[i][j];
                dp[i+1][j+1] %= MOD;
            }
            else {
                dp[i+1][j] += dp[i][j];
                dp[i+1][j] %= MOD;
            }
        }
    }

    cout << dp[h][k-1] << endl;

}

#include <algorithm>
#include <iostream>
#include <vector>
#include <numeric>
using namespace std;
#define bit(n, k) ((n) >> (k) & 1)
const int MOD = (int)1e9 + 7;
template<class T> void add(T &a, T b) { (a += (b % MOD + MOD) % MOD) %= MOD; }

int main() {
    int h, w; cin >> h >> w;
    int K; cin >> K; K--;
    vector<vector<int>> num(w, vector<int>(w));
    for (int mask = 0; mask < 1 << (w - 1); mask++) {
        bool ok = true;
        for (int i = 0; i + 1 < w - 1; i++) {
            if (bit(mask, i) && bit(mask, i + 1)) ok = false;
        }
        if (!ok) continue;
        vector<int> p(w);
        iota(p.begin(), p.end(), 0);
        for (int i = 0; i < w - 1; i++) if (bit(mask, i)) swap(p[i], p[i + 1]);
        for (int i = 0; i < w; i++) num[i][p[i]]++;
    }
    vector<vector<long long>> dp(h + 1, vector<long long>(w));
    dp[0][0] = 1;
    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) for (int k = 0; k < w; k++) {
            add(dp[i + 1][k], dp[i][j] * num[j][k]);
        }
    }
    cout << dp[h][K] << endl;
    return 0;
}


#include <iostream>
#include <string>

using namespace std;

char decode(char c, int n) {
  if ('a' <= c && c <= 'z') {
    if (c - 'a' >= n)
      return c-n;
    else
      return decode('Z', n-(c-'a'+1));
  }
  if ('A' <= c && c <= 'Z') {
    if (c - 'A' >= n)
      return c-n;
    else
      return decode('z', n-(c-'A'+1));
  }
}

int main() {
  int len;
  while(cin >> len, len) {
    int list[len];
    for(int i=0; i<len; i++)
      cin >> list[i];
    string s;
    cin >> s;
    for(int i=0; i<s.size(); i++)
      s[i] = decode(s[i],list[i%len]);
    cout << s << endl;
  }
}

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
//const ll mod = 1000000007;
ll N, x[100500], M, K, a[100050];
ll dp[100050][70];
ll ans_delta[100050];
int f(int index, ll time) {
    //cout << index << " " << time << endl;
    if(time == 0) {
        return index;
    }
    ll now = 1;
    ll dp_index = 0;
    while(now * 2 <= time) {
        now *= 2;
        dp_index++;
    }
    int NEW = dp[index][dp_index];
    return f(NEW, time - now);
}

int main() {
    cout.precision(10);
    cin >> N;
    for(int i = 1; i <= N; i++) {
        cin >> x[i];
    }
    cin >> M >> K;
    //cout << N << " " << M << " " << K << endl;
    for(int i = 1; i <= M; i++) {
        cin >> a[i];
    }
    for(int i = 1; i < N; i++) {
        dp[i][0] = i;
    }
    for(int i = 1; i <= M; i++) {
        swap(dp[a[i] - 1][0], dp[a[i]][0]);
    }
    for(int i = 1; i < N; i++) {
        //cout << i << " " << dp[i][0] << endl;
    }
    for(int i = 1; i < 70; i++) {
        for(int delta = 1; delta < N; delta++) {
            int before = dp[delta][i - 1];
            dp[delta][i] = dp[before][i - 1];
            //cout << i << " " << delta << " " << dp[delta][i] << endl;
        }
    }
    for(int i = 1; i < N; i++) {
        ans_delta[i] = f(i, K);
        //cout << i << " " << ans_delta[i] << endl;
    }
    ll sum = x[1];
    cout << sum << endl;
    for(int i = 1; i < N; i++) {
        ll delta = x[ans_delta[i] + 1] - x[ans_delta[i]];
        sum += delta;
        cout << sum << endl;
    }
    return 0;
}


#include <bits/stdc++.h>
#define REP(i,n) for (int i=0;i<(n);i++)
#define ALL(a) (a).begin(),(a).end()
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define rep(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define ll long long
#define ull unsigned long long
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

using namespace std;

int main(){
  int e;
  while(cin>>e,e){
		int ans = 1 << 20;
        for(int i = 0;i*i*i<=e;i++){
					int yyx  = e - i*i*i;
					int y = (int)sqrt(yyx);
					ans = min(yyx-y*y+y+i,ans);
				}
				cout << ans << endl;
  }
  return 0;
}

#include <iostream>
#include <cstring>
using namespace std;

const char i = 'I', v = 'V', x = 'X', l = 'L', c = 'C', d = 'D', m = 'M';

int number(char s)
{
     switch (s) {
     case i: return 1;
     case v: return 5;
     case x: return 10;
     case l: return 50;
     case c: return 100;
     case d: return 500;
     case m: return 1000;
     }
}

int main()
{
     string str;
     while (cin >> str) {
          int i = 0;
          int ans = 0;
          while (i < str.size()) {
               int tmp = 0;
               char s = str[i];
               while (s == str[i] && i < str.size()) {
                    tmp += number(s);
                    i++;
               }
               if (number(s) < number(str[i])) ans -= tmp;
               else ans += tmp;
          }
          cout << ans << endl;
     }

     return 0;
}


#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define cinf(n,x) for(int i=0;i<(n);i++)cin>>x[i];
#define ft first
#define sc second
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(),(v).end()
#define mod 1000000007
#define FS fixed<<setprecision(15)
using namespace std;
typedef long long ll;
template<class T> using V=vector<T>;
using Graph = vector<vector<int>>;
using P=pair<ll,ll>;
typedef unsigned long long ull;
typedef long double ldouble;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

const ll INF=1e18;

ll s[200005],t[200005];

ll mod_pow(ll x,ll n,ll m){
    if(n==0) return 1;
    ll res=mod_pow(x*x%m,n/2,m);
    if(n&1) res=res*x%m;
    return res;
}

int main(){
    ll n,m,k;
    cin>>n>>m>>k;
    ll A=n*m;
    ll B=A-2;
    ll ans=0;
    ll cnt=1;
    ll c;
    ll ma=n+m-2;
    s[0]=t[0]=0;
    for(ll i=1;i<=ma+2;i++){
        s[i]=i*(i+1)/2;
        t[i]=i*(i+1)*(i+2)/6;
    }
    for(ll i=0;A-2-i>A-k;i++) cnt=(cnt*(A-2-i))%mod;
    for(ll i=2;i<=k-2;i++) cnt=(cnt*mod_pow(i,mod-2,mod))%mod;
    c=cnt;
    ll i=1,j=1;
    while(true){
        ll now=0;
        now=(now+s[m-j])%mod;
        if(j==1){
            now=(now+(t[m-j+n-i]-t[m-j]-t[n-i-1])%mod)%mod;
        }else if(j==m){
            now=(now+(t[j+n-i-1]-t[j-1]-t[n-i-1])%mod)%mod;
        }else{
            now=(now+(t[m-j+n-i]-t[m-j]-t[n-i-1])%mod)%mod;
            now=(now+(t[j+n-i-1]-t[j-1]-t[n-i-1])%mod)%mod;
            now-=s[n-i];
            while(now<0) now=now+mod;
        }
        ans=(ans+(now*cnt)%mod)%mod;
        if(j==m){
            i++;j=1;
        }else{
            j++;
        }
        if(i==n&&j==m) break;
    }
    cout<<ans<<endl;
}

#include <iostream>
#include <bits/stdc++.h>
#define ll long long

using namespace std;
const ll Mod = 1e9 + 7;
ll fact[200100];

long long fastpower(long long a,long long b)
{
    if(b==0)
        return 1;
    if(b==1)
        return a;
    long long res = fastpower(a,b/2)%Mod;
    res = (res %Mod  * res % Mod )%Mod;
    if(b%2!=0)
        res*=a;
    return res % Mod;
}

ll C(ll n , ll k){

    if(n < k)  return 0;
    ll x = fact[n];
    ll y = (fact[k] * fact[n - k])%Mod;
    return ((x * fastpower(y , Mod - 2))%Mod);
}

void add_self(ll &x , ll y){
    x = (x + y)%Mod;
}

void sub_self(ll &x , ll y){
    x = ((x - y)%Mod)+Mod;
}

vector < ll > v , v2;

int main()
{
    ll n,m,k;  cin >> n >> m >> k;
    fact[0] = 1;
    for(int i = 1;i<=200000;i++)  fact[i] = (fact[i - 1] * i) % Mod;
    ll sum = 0;
    for(int i = 1;i<=n;i++){
        for(int j = 1;j<=m;j++){
            v.push_back(i);
            v2.push_back(j);
        }
    }
    sort(v.begin() , v.end());
    sort(v2.begin() , v2.end());
    ll Ans = 0;
    for(ll i = 0;i<v.size();i++){
        ll Ways  = C(n * m - 2 , k - 2);
        sub_self(Ans , v[i] * ((ll)v.size() - (i + 1)) * Ways +  Mod);
        add_self(Ans , v[i] * i % Mod * Ways);
    }
    for(ll i = 0;i<v2.size();i++){
        ll Ways  = C(n * m - 2 , k - 2);
        sub_self(Ans , v2[i] * ((ll)v2.size() - (i + 1)) * Ways + Mod);
        add_self(Ans , v2[i] * i % Mod * Ways);
    }
    cout << Ans;
    return 0;
}


#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bitset>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<list>
#include<iomanip>
#include<cmath>
#include<cstring>
#include<functional>
#include<cstdio>
#include<cstdlib>
using namespace std;

#define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) repr(i, 0, n)
#define INF 2e9
#define MOD 1000000007
//#define MOD 998244353
#define LINF (long long)4e18
#define jck 3.141592

const double EPS = 1e-10;

using ll = long long;
using Pi = pair<int,int>;
using Pl = pair<ll,ll>;

int main(){
    int n; cin >> n;
    vector<ll> a(n);
    rep(i,n){
        double b;
        cin >> b;
        b *= 1000000000;
        a[i] = (ll)(b+0.0005);
    }
    map<Pi,int> cnt;
    rep(i,n){
        ll now = a[i];
        int cnt2 = 0;
        while(now%2 == 0){
            cnt2++;
            now /= 2;
        }
        now = a[i];
        int cnt3 = 0;
        while(now%5 == 0){
            cnt3++;
            now /= 5;
        }
        cnt[Pi(cnt2,cnt3)]++;
    }
    ll ans = 0;
    ll ans2 = 0;
    for(auto p1: cnt){
        for(auto p2: cnt){
            if(p1.first.first+p2.first.first >= 18 && p1.first.second+p2.first.second >= 18){
                if(p1 == p2){
                    ans2 += (ll)p1.second*(p1.second-1)/2;
                }
                else ans += (ll)p1.second*p2.second;
            }
        }
    }
    ans = ans/2+ans2;
    cout << ans << endl;
}

#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<vector>
#include<functional>
#include<algorithm>
#include<stdlib.h>
#include<string>
#include<string.h>
#define _USE_MATH_DEFINES
#include<math.h>
#include<deque>
#include<set>
#include<map>
#include<queue>
#include<list>
#include<iostream>
#include <bitset>
using namespace std;
typedef long long ll;
#define rep(i,a,b) for(auto i=a;i<b;i++)
#define all(_x) _x.begin(), _x.end()
#define r_sort(_x) sort(_x.begin(), _x.end(), std::greater<int>())
#define vec_cnt(_a, _n) (upper_bound(all(_a), _n) - lower_bound(all(_a), _n))
#define vec_unique(_a) _a.erase(std::unique(all(_a)), _a.end());
#define vvec vector<vector<ll>>
ll gcd(ll a, ll b) { return a % b == 0 ? b : gcd(b, a % b); }
ll lcm(ll a, ll b) { return (a / gcd(a, b)) * b; }
#define INF 1 << 30
const int mod = 1000000007;
ll power(ll x, ll p) { ll a = 1; while (p > 0) { if (p % 2 == 0) { x *= x; p /= 2; } else { a *= x; p--; } }return a; }
ll mpower(ll x, ll p) { ll a = 1; while (p > 0) { if (p % 2 == 0) { x = x * x % mod; p /= 2; } else { a = a * x % mod; p--; } }return a; }
ll ac(ll n, ll k) { ll a = 1; rep(i, 1, k) { a *= n - i + 1; a /= i; }return a; }
ll mc(ll n, ll m) { ll k = 1, l = 1; rep(i, n - m + 1, n + 1) k = k * i % mod; rep(i, 1, m + 1) l = l * i % mod; l = mpower(l, mod - 2); return k * l % mod; }
struct UnionFind {
	vector<int> par;
	UnionFind(int N) : par(N) { rep(i, 0, N)par[i] = i;}
	int root(int x) { return par[x] == x ? x : par[x] = root(par[x]);}
	void unite(int x, int y) {if (!same(x, y)) par[root(x)] = root(y); }
	bool same(int x, int y) {return root(x) == root(y);}
};
int main()
{
	int H, W;
	ll ans = 0;
	cin >> H >> W;
	vector<string> S(H);
	UnionFind tree(W * H);
	rep(i, 0, H)cin >> S[i];
	rep(i, 0, H) {
		rep(i2, 0, W) {
			if (i != H - 1 && S[i][i2] != S[i + 1][i2]) {
				tree.unite(i * W + i2, i * W + W + i2);
			}
			if (i2 != W - 1 && S[i][i2] != S[i][i2 + 1]) {
				tree.unite(i * W + i2, i * W + 1 + i2);
			}
		}
	}
	map<int, pair<int, int>>mp;
	rep(i, 0, H * W) {
		if(S[i / W][i % W] == '#')mp[tree.root(i)].first++;
		else mp[tree.root(i)].second++;
	}
	for (auto m : mp) {
		ans += (ll)m.second.first * m.second.second;
	}
	printf("%lld\n", ans);
	return 0;
}


#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <algorithm>
#include <utility>
typedef long long ll;
const int INF = 1e9+1;
const int MOD = 2e9 + 9;
const ll LINF = 1e18;
using namespace std;

int main(){
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	cout << min(a, b) + min(c, d);
	return 0;
}

#include<bits/stdc++.h>
using namespace std;

int main()
{
    int n, input;
    cin >> n;

    int mn = n, cnt = 0;

    for(int i = 0; i < n; i++){
        cin >> input;
        if(input < mn)
            mn = input;
        if(mn >= input)
            cnt++;
    }

    cout << cnt;

    return 0;
}


#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#define f(x) x*x
using namespace std;
int ans;
int main(){
    int ma,n;
    while(cin>>n){
        for(int i=n;i<600;i+=n){
            ans += (f(i) * n);
        }
        cout<<ans<<endl;
        ans=0;
    }
return 0;
}

#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
using namespace std;

int main()
{
	int n,r;
	scanf("%d%d",&n,&r);
	int ans;
	if(n<10)
	{
		ans=r+(10-n)*100;
	}
	else ans=r;
	printf("%d",ans);
}


#include<bits/stdc++.h>
using namespace std;

int main(){
  int a, b;
  cin >> a >> b;
  if((b - 1) % (a - 1) == 0){
    cout << (b - 1) / (a - 1) << endl;
  } else{
    cout << (b - 1) / (a - 1) + 1 << endl;
  }
  return 0;
}

#include<bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(),v.end()
#define puts(i) cout << i << endl
#define INF INT_MAX;
#define INFL LLONG_MAX;
typedef long long ll;
using namespace std;
int main(){

int A,B,i,sum=1,count=0;

cin >> A >> B;

for(i=0;i==0;i){

  if(sum<B){
    sum=sum-1+A;
    count++;
  }
  else{
    break;
  }
}
cout << count << endl;
}


#include <bits/stdc++.h>
using namespace std;

typedef long long lli;
typedef vector<int> Vi;
typedef vector<lli> Vl;
typedef pair<int, int> Pii;
typedef pair<lli, lli> Pll;

//===

const int MOD = (int)1e9 + 7;

int main()
{
	int N, X;
	cin >> N >> X;
	vector<int> S(N);
	for (int i = 0; i < N; ++i) cin >> S[i];

	sort(S.begin(), S.end());

	vector<Vl> dp(N + 1, Vl(X + 1));
	for (int x = 0; x <= X; ++x) dp[0][x] = x;

	for (int i = 0; i < N; ++i) {
		for (int x = 0; x <= X; ++x) {
			dp[i + 1][x] = (dp[i][x % S[i]] + i * dp[i][x]) % MOD;
		}
	}

	cout << dp[N][X] << endl;
}

#include <bits/stdc++.h>
using namespace std;

int main()
{
	int n, k; cin >> n >> k;
	vector<double> v(n);
	vector<double> expected(n);
	for(int i = 0; i < n; ++i)
	{
		cin >> v[i];
		expected[i] = ((v[i]*(v[i]+1.0))/2.0)/v[i];

		if(i)
			expected[i] += expected[i-1];

	}
	double maxi = expected[k-1];
	double tolerance = 0.0000001;
	for(int i = k-1; i < n; ++i)
	{
		int pre = i - k;
		if(pre >= 0)
		{
			double cur = expected[i] - expected[pre];
			if(cur-maxi > tolerance)
				maxi = cur;
		}
	}

	cout << setprecision(17) <<  maxi;

	return 0;

}


#include <iostream>
using namespace std;

bool check(string S){
  if(S[0]!='A') return false;
  int C=0;
  for (int i = 2 ; i < S.length()-1; i++) {
    if(S[i]=='C'){
      C++;
    }
  }
  if(C!=1) return false;
  int upper=0;
  for (int i = 0; i < S.length(); i++) {
    if(S[i]>='A'&&S[i]<='Z'){
      upper++;
    }
  }
  if(upper!=2) return false;
  return true;
}

int main(){
  string S;
  cin >> S;
  if(check(S)){
    cout << "AC" << endl;
  } else {
    cout << "WA" << endl;
  }
}

#include <iostream>
#include <string>
#include <algorithm>
#include <math.h>
using namespace std;

void b_accepted(void) {
	string s;
	cin >> s;
	bool judge_a = false, judge_b = false, judge_c = false;

	int cnt_c = 0;
	for (int i = 0; i < s.size(); i++) {
		if (i == 0) {
			if (s[i] == 'A') judge_a = true;
			else             break;
		}
		else if (s[i] == 'C'){
			if (i >= 2 && i < s.size() - 1) {
				cnt_c++;
			}
		}
		else {
			if (s[i] < 'a') {
				judge_c = false;
				break;
			}
			else judge_c = true;
		}
	}

	if (cnt_c == 1) judge_b = true;

	if (judge_a & judge_b & judge_c) {
		cout << "AC" << endl;
	}
	else {
		cout << "WA" << endl;
	}
}

int main()
{
	b_accepted();
    return 0;
}


#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii =  pair<int, int>;
using pll =  pair<long long, long long>;
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007LL;
constexpr long long INF = 1000000000LL;
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main(){
  int n, k;
  cin >> n >> k;
  if(n % k == 0) cout << 0 << ln;
  else cout << 1 << ln;
}

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = 1e16;
const ll mod = 1000000007;
#define rep(i, n) for (int i = 0; i < (ll)(n); i++)

int main() {
  ll n, m; cin >> n >> m;
  ll res = 1;
  for (ll i = 1; i*i <= m; i++) {
    if (m%i == 0) {
      if (i*n <= m) res = max(res, i);
      if (m/i != i) {
        if (m/i*n <= m) res = max(res, m/i);
      }
    }
  }
  cout << res << endl;
}


#include<bits/stdc++.h>
using namespace std;
int main(){
  int A,B;
  cin>>A>>B;
   //if(B<=A) cout<<0<<endl;
  if(B==1) cout<<0<<endl;
  else if(A==B) cout<<1<<endl;
  else if((B-A)%(A-1)==0) cout<<(B-1)/(A-1)<<endl;
  else cout<<1+(B-1)/(A-1)<<endl;
}

#include <bits/stdc++.h>
using namespace std;
#define rep(i, s, n) for (int i = (s); i < (int)(n); i++)

int main(){
    int a,b,ans,pl;
    cin >> a >> b;
    pl=1;
    for(ans=0;pl<b;ans++){
        pl += a-1;
    }
    cout << ans << endl;
}


#include <bits/stdc++.h>
using namespace std;

int N,M;
int FS[310][310];
vector<int>K;

int main(){
  cin>>N>>M;
  for(int i=0;i<N;i++){
    for(int j=0;j<M;j++){
      cin>>FS[i][j];
    }
  }
  for(int i=1;i<=M;i++){
    K.push_back(i);
  }
  int eachmaxcnt=0;
  int maxcnt=300;
  int C[310];
  int temp=0;

  //ゲームの種類分回す
  for(int i=0;i<M;i++){

    //各ゲームの参加者数を初期化
    for(int i=1;i<=M;i++){
      C[i]=0;
    }
      for(int i=0;i<N;i++){
        for(int j=0;j<M;j++){
          //最初にでてくるゲームの参加者を加算
          if(FS[i][j] != -1){
            C[FS[i][j]]++;
            break;
          }
        }
    }

    //最大参加者数を求める
    eachmaxcnt=0;
    for(int i=1;i<=M;i++){
      if(eachmaxcnt<C[i]){
        eachmaxcnt=C[i];
        temp=i;
      }
    }

    //最大参加者数の更新
    maxcnt=min(maxcnt,eachmaxcnt);

    //最大参加者のゲームを-1にする
    for(int i=0;i<N;i++){
      for(int j=0;j<M;j++){
        if(FS[i][j]==temp){
          FS[i][j]=-1;
        }
      }
    }
  }

  cout<<maxcnt<<endl;
  return 0;
}

#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <algorithm>
using namespace std;
const int maxn = 2010;
bool board[maxn][maxn];
int n, m;
int len[2][maxn][maxn];
void init(bool asd)
{
	//cout << asd << " : " << endl;
	for(int i = 1; i <= m; i ++)
		len[asd][1][i] = m + 1;
	for(int i = 2; i <= n; i ++)
	{
		int p = 0;
		for(int j = 1; j <= m; j ++)
		{
			p = max(p, j);
			for(p; p <= m && board[i][p] == (board[i - 1][p] ^ asd); p ++);
			//cout << i << " " << j << " " << p << endl;
			len[asd][i][j] = p;
		}
	}
	/*
	for(int i = 1; i <= n; i ++)
	{
		for(int j = 1; j <= m; j ++)
			cout << len[asd][i][j] << " ";
		cout << endl;
	}
	*/
}
int ans = 0;
int sta[maxn], cnt = 0;
int l[maxn];
void get(int x)
{
	//cout << x << " ---------------------- " << endl;
	cnt = 0;
	sta[++ cnt] = 1;
	l[1] = 0;
	for(int i = 2; i <= n; i ++)
	{
		l[i] = max(len[0][i][x], len[1][i][x]) - x;
		//cout << i << " " << l[i] << endl;
		while(cnt > 0 && l[sta[cnt]] > l[i])
		{
			//cout << sta[cnt] << " : " << endl;
			ans = max(ans, (i - sta[cnt - 1]) * l[sta[cnt]]);
			//cout << ans << endl;
			cnt --;
		}
		sta[++ cnt] = i;
	}
	while(cnt > 0)
	{
		ans = max(ans, (n - sta[cnt - 1] + 1) * l[sta[cnt]]);
		cnt --;
	}
}
int main()
{
	std::ios::sync_with_stdio(false);
	cin >> n >> m;
	for(int i = 1; i <= n; i ++)
	{
		for(int j = 1; j <= m; j ++)
		{
			char a;
			cin >> a;
			if(a == '#')
				board[i][j] = 1;
			else
				board[i][j] = 0;
		}
	}
	init(0);
	init(1);
	for(int a = 1; a <= m; a ++)
		get(a);
	cout << max(ans, max(n, m)) << endl;
	return 0;
}


#include "bits/stdc++.h"
using namespace std;
///////////////////////////////////////////
const long long int INF = 1LL<<60;
const long long int Mod = 1000000007;
using ll = long long int; using ci = const int;
using vi = vector<int>;  using Vi = vector<long long int>;
using P = pair<int, int>;  using PLL = pair<ll, ll>;
using matrix = vector<vector<ll>>;
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define rep(i,N) for(ll i = 0; i < (ll)N; i++)
#define repi(i,a,b) for(ll i = ll(a); i < ll(b); ++i)
template<class T>bool chmax(T &former, const T &b) { if (former<b) { former=b; return true; } return false; }
template<class T>bool chmin(T &former, const T &b) { if (b<former) { former=b; return true; } return false; }
template<class T>T sqar(T x){ return x*x; }//sqrt(x)は平方根;
#define Sort(v) std::sort(v.begin(), v.end(), std::greater<decltype(v[0])>()) //降順でVをソート
#define p_queue(v) priority_queue<v, vector<v>, greater<v> >
template<class T> inline void princ(T x){cout<<x<<" ";};
template<class T> inline void print(T x){cout<<x<<"\n";};
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
///////////////////////////////////////////////////////////////////////////////////

string s;

int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    std::cout<<std::fixed<<std::setprecision(30);
    cin>>s;
    ll aa = -1,bb = -1;
    rep(i,s.size()){
        if(i-1>=0){
            if(s[i]==s[i-1]){
                aa = i;
                bb = i+1;
                break;
            }
        }
        if(i-2>=0){
            if(s[i-2]==s[i]){
                aa = i-1;
                bb = i+1;
                break;
            }
        }
    }
    cout<<aa<<" "<<bb<<endl;
    return 0;
}

#include <bits/stdc++.h>
using namespace std;

int main() {
  string S;
  cin >> S;
  int res = 100000;
  for (int i = 0; i + 2 < S.size(); ++i) {
    int val = (S[i]-'0')*100 + (S[i+1]-'0')*10 + (S[i+2]-'0');
    res = min(res, abs(val - 753));
  }
  cout << res << endl;
}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair< ll, ll > Pi;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep2(i,n) for(int i=1;i<=(n);i++)
#define rep3(i,i0,n) for(int i=i0;i<(n);i++)
#define pb push_back
#define mod 1000000007
const ll INF = 1LL << 60;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
ll gcd(ll a, ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) {return a/gcd(a,b)*b;}
#define all(x) x.begin(), x.end()
#define mp make_pair
bool compare(Pi a, Pi b) {
    if(a.first != b.first){
        return a.first < b.first;

    }else{
        return a.second < b.second;
    }
}

bool In_map(ll y,ll x,ll h,ll w){
    if(y<0 || x<0 || y>=h || x>=w){
        return 0;
    }else{
        return 1;
    }
}
const vector<ll> dx{1,0,-1,0};
const vector<ll> dy{0,1,0,-1};

int main() {
    ll x;
    cin >>x;
    ll ans;
    if(x%11==0){
        ans=x/11*2;
    }else if((x-x/11*11)<=6){
        ans=x/11*2+1;
    }else{
        ans=x/11*2+2;
    }

    cout << ans<< endl;

    return 0;

}

#include <bits/stdc++.h>
#define pb push_back
#define ll long long
#define f first
#define s second
using namespace std;
int n, m, a[200001];
int main(){
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    int t; cin >> t;
    if(t < 1200)cout << "ABC" << endl;
    else if(t < 2800)cout << "ARC" << endl;
    else cout << "AGC" << endl;
    return 0;
}


/*
g++ --std=c++17 A.cpp
*/

#include <iostream>
#include <iomanip> //! for setprecision(20)
#include <math.h>
#include <algorithm>
#include <functional>
#include <string>
#include <vector>

#include <cstring>
#include <set>
#include <map>
#include <queue>
#include <utility>
#include <limits.h>

using namespace std;

typedef long long LL;

#define rep(i,n) for (int i = 0; i < int(n); ++i)
#define dump(c) { for (auto it = c.begin(); it != c.end(); ++it) if (it == c.begin()) cout << *it; else cout << ' ' << *it; cout << endl; }
#define dumpMap(m) { for (auto it: m) cout << it.first << "=>" << it.second << ' '; }

const int dx[4] = { 0, -1, 1, 0 };
const int dy[4] = { -1, 0, 0, 1 };

const int MOD = 1000000007;

int dist[50][50];
string s[50];

int main()
{
    const int INF = 1e9;
	cin.tie(0);
	ios::sync_with_stdio(0);

    int h, w;
    cin >> h >> w;
    rep(i, h) cin >> s[i];
    int whiteCount = 0;
    rep(y, h) rep(x, w) {
        dist[y][x] = INF;
        if (s[y][x] == '.') ++whiteCount;
    }
    dist[0][0] = 1;
    queue<pair<int, int>> q;
    q.push({0, 0});
    while (!q.empty()) {
        int y = q.front().first; int x = q.front().second; q.pop();
        int d = dist[y][x] + 1;
        rep(i, 4) {
            int ny = y + dy[i];
            int nx = x + dx[i];
            if (0 <= ny && ny < h && 0 <= nx && nx < w && s[ny][nx] == '.' && d < dist[ny][nx]) {
                dist[ny][nx] = d;
                q.push({ny, nx});
            }
        }
    }

    int ans = -1;
    if (dist[h-1][w-1] != INF) {
        ans = whiteCount - dist[h-1][w-1];
    }
    cout << ans << endl;

    return 0;
}

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
ll MOD = 1000000007;

int main(){
  int H,W;cin >> H >> W;
  vector<string> S(H);
  int cnt=0;
  for(int i=0;i<H;i++){
    cin >> S[i];
    for(int j=0;j<W;j++){
      if(S[i][j]=='#'){
        cnt ++;
      }
    }
  }
  vector<vector<bool>> P(H,vector<bool>(W,false));
  queue<int> X;
  queue<int> Y;
  queue<int> D;
  X.push(0);
  Y.push(0);
  D.push(1);
  P[0][0] = true;
  int goalD=0;
  while(!X.empty()){
    int x = X.front(),y=Y.front(),d=D.front();
    X.pop();Y.pop();D.pop();
    if(x==H-1&&y==W-1){
      goalD = d;
      break;
    }
    if(x-1>=0){
      if(S[x-1][y]=='.'&&!P[x-1][y]){
        X.push(x-1);Y.push(y);D.push(d+1);
        P[x-1][y] = true;
      }
    }
    if(x+1<H){
      if(S[x+1][y]=='.'&&!P[x+1][y]){
        X.push(x+1);Y.push(y);D.push(d+1);
        P[x+1][y] = true;
      }
    }
    if(y-1>=0){
      if(S[x][y-1]=='.'&&!P[x][y-1]){
        X.push(x);Y.push(y-1);D.push(d+1);
        P[x][y-1] = true;
      }
    }
    if(y+1<W){
      if(S[x][y+1]=='.'&&!P[x][y+1]){
        X.push(x);Y.push(y+1);D.push(d+1);
        P[x][y+1] = true;
      }
    }
  }
  if(P[H-1][W-1]){
    cout << H*W - cnt - goalD << endl;
  }else{
    cout << -1 << endl;
  }
}


#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
using namespace std;

int main() {
	int sum = 0;
	vector<int> vec_1(4); vector<int> vec_2(2);
	for (int i = 0; i < 4; i++) cin >> vec_1[i];
	for (int i = 0; i < 2; i++) cin >> vec_2[i];
	sort(vec_1.begin(), vec_1.end(), greater<int>());
	sort(vec_2.begin(), vec_2.end(), greater<int>());
	for (int i = 0; i < 3; i++) sum += vec_1[i];
	for (int i = 0; i < 1; i++) sum += vec_2[i];
	cout << sum << endl;
	return 0;
}

#include<stdio.h>
int main(void)
{
	int n,x,cnt[10],i,j;
	while(1){
		for(i=0;i<10;i++){
			cnt[i]=0;
		}
		scanf("%d",&n);
		if(n<1)break;
		for(i=0;i<n;i++){
			scanf("%d",&x);
			cnt[x]++;
		}
		for(i=0;i<10;i++){
			if(cnt[i]>0){
				for(j=0;j<cnt[i];j++){
					printf("*");
				}
				printf("\n");
			}
			else{
				printf("-\n");
			}
		}
	}
	return 0;
}


#include <bits/stdc++.h>

using namespace std;

#define forn for (ll i = 0; i < n; i++)
#define form for (ll j = 0; j < m; j++)
#define NO cout << "NO\n";
#define YES cout << "YES\n";
#define pb push_back
#define mp make_pair
#define rep(i,a,b) for (ll i = a; i < b; i++)

typedef long long ll;
typedef vector<ll> vi;
typedef pair<ll, ll> pi;

ll gcd(ll a, ll b){
    ll r;
    while (b != 0){
        r = a % b;
        a = b;
        b = r;
    }
    return a;
}

ll *calc_z(string s){
    ll n = s.size();
    ll *z = new ll[n] {0};
    ll l = 0, r = 0;
    for (ll i = 1; i < n; i++){
        if (r >= i) z[i] = min(z[i-l], r-i+1);
        while (z[i]+i < n && s[z[i]] == s[z[i]+i]) z[i]++;
        if (i + z[i] - 1 > r){
            l = i;
            r = i+z[i]-1;
        }
    }
    return z;
}

ll find_lower(ll *a, ll n, ll v){
    ll l = -1, r = n;

    while (r>l+1){
        ll m = (l+r)/2;

        if (a[m] >= v) r = m;
        else l = m;
    }
    if (r == n) return n-1;
    if (a[r] == v) return r;
    return r == 0 ? 0 : r-1;
}

void init(){
}

int bin(int *p, int n, int x){
    int l = 0, r = n-1;
    while (r >= l){
        int m = (l+r)/2;
        if (p[m] == x) return m;
        if (p[m] > x) r = m-1;
        else l = m+1;
    }
    return -1;
}

void solve(){
    ll a, b;
    cin >> a >> b;
    cout << a*b << '\n';
}

int main(){
    //init();

    ios::sync_with_stdio(0);
    cin.tie(0);

    //ll t; cin >> t; while (t--)
        solve();
    return 0;
}

#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <algorithm>
#include <climits>
#include <cstring>
#include <cmath>
#include <stack>
#include <iomanip>
#include <tuple>
#include <functional>
#include <cfloat>
#include <map>
#include <set>
#include <array>
#include <stdio.h>
#include <string.h>
using ll = long long;
using ull = unsigned long long;
using namespace std;
#define int long long
#define CONTAINS_VEC(v,n) (find((v).begin(), (v).end(), (n)) != (v).end())
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
#define ARY_SORT(a, size) sort((a), (a)+(size))
#define REMOVE(v,a) (v.erase(remove((v).begin(), (v).end(), (a)), (v).end()))
#define REVERSE(v) (reverse((v).begin(), (v).end()))
#define ARY_REVERSE(v,a) (reverse((v), (v)+(a)))
#define REP(i, n) for (int (i)=0; (i) < (n); (i)++)
#define CONTAINS_MAP(m, a) (m).find((a)) != m.end()
#define CONTAINS_SET(m, a) (m).find((a)) != m.end()
void YesNo(bool b) { cout << (b ? "Yes" : "No") << endl; }
void YESNO(bool b) { cout << (b ? "YES" : "NO") << endl; }

signed main()
{
	int N, A, B;
	cin >> N;
	if (N == 1)
	{
		cout << "Hello World" << endl;
	}
	else
	{
		cin >> A >> B;
		cout << A + B << endl;
	}
}


#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <math.h> // sqrt
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <iomanip> // setprecision
using namespace std;
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vb = vector<bool>;
using vll = vector<long long>;
using pii = pair<int, int>;
using psi = pair<string, int>;

int main() {
    string sa, sb, sc;
    cin >> sa >> sb >> sc;
    deque<char> da, db, dc;
    for (char c : sa) {
        da.push_back(c);
    }
    for (char c : sb) {
        db.push_back(c);
    }
    for (char c : sc) {
        dc.push_back(c);
    }
    bool A = true, B = false;
    while(true) {
        if (A) {
            if (da.empty()) {
                cout << "A" << endl;
                return 0;
            }
            if (da.front() == 'b') {
                B = true;
                A = false;
            }
            else if (da.front() == 'c') {
                A = false;
            }
            da.pop_front();
        }
        else if (B) {
            if (db.empty()) {
                cout << "B" << endl;
                return 0;
            }
            if (db.front() == 'a') {
                A = true;
                B = false;
            }
            else if (db.front() == 'c') {
                B = false;
            }
            db.pop_front();
        }
        else {
            if (dc.empty()) {
                cout << "C" << endl;
                return 0;
            }
            if (dc.front() == 'a') {
                A = true;
            }
            else if (dc.front() == 'b') {
                B = true;
            }
            dc.pop_front();
        }
    }
}

#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math")
#include <bits/stdc++.h>
using namespace std;
template<class t> inline t read(t &x){
	char c=getchar();bool f=0;x=0;
	while(!isdigit(c)) f|=c=='-',c=getchar();
	while(isdigit(c)) x=(x<<1)+(x<<3)+(c^48),c=getchar();
	if(f) x=-x;return x;
}
template<class t,class ...A> inline void read(t &x,A &...a){
	read(x);read(a...);
}
template<class t> inline void write(t x){
	if(x<0) putchar('-'),write(-x);
	else{if(x>9) write(x/10);putchar('0'+x%10);}
}

int ans,x,y;

signed main(){
	read(x,y);
	if(x==1) ans+=3e5;
	if(x==2) ans+=2e5;
	if(x==3) ans+=1e5;
	if(y==1) ans+=3e5;
	if(y==2) ans+=2e5;
	if(y==3) ans+=1e5;
	if(x==1&&y==1) ans+=4e5;
	write(ans);
}


#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define fi first
#define se second
#define mp make_pair
#define itrfor(itr,A) for(auto itr = A.begin(); itr !=A.end();itr++)
template <class T> using reversed_priority_queue = priority_queue<T, vector<T>, greater<T> >;
typedef long long llong;
char moji[26]={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
char moji2[26]={'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
char moji3[10]={'0','1','2','3','4','5','6','7','8','9'};
#define Sort(a) sort(a.begin(),a.end());
#define Reverse(a) reverse(a.begin(),a.end());
#define print(a) cout << a << endl;
#define MOD llong(1e9+7)
#define MAX int(2 * 1e5 +5)
#define debug(x)  cout << #x << " = " << (x) << endl;
#define pi acos(-1.0)
#define int llong
#define INF llong(1e17)
template<class T> bool chmax(T &a,  T b) {if(a<b){a=b; return 1;} return 0;}
template<class T> bool chmin(T &a,  T b) {if(a>b){a=b; return 1;} return 0;}
bool Add(int &a,int b){a = (a + b) % MOD;}
void myprint(int* A,int A_num){
   REP(i,A_num) cout << A[i] << " ";
   cout << endl;
}

const int x_max = 100004;
const int n_max = 205;

signed main(){
    int n,x;
    cin >> n >> x;
    int A[n];
    REP(i,n) cin >> A[i];
    sort(A,A+n);

    int dp[2][x_max];
    REP(j,x_max) dp[0][j] = j % A[0];
    FOR(i,1,n){
        REP(j,x_max){
            dp[i%2][j] = 0;
            Add(dp[i%2][j],dp[(i-1)%2][j % A[i]]);
            Add(dp[i%2][j],i * dp[(i-1)%2][j]);
        }
    }
    cout << dp[(n-1)%2][x] << endl;

}

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 200 + 10, M = 100000 + 10;
const int mod = 1e9 + 7;
void add(ll &x,ll y){
    x += y;
    if(x>=mod) x -= mod;
}
ll qpow(ll n,ll k){
    ll res = 1;
    while(k){
        if(k&1) res = res * n % mod;
        n = n * n % mod;
        k >>= 1;
    }
    return res;
}
ll fac[N],inv[N];
ll push(int x,int y){
    return fac[x+y] * inv[x] % mod;
}
int a[N],n;
ll f[N][M];
ll calc(int i,int j){
    if(j<a[n]){
//        cout<<i<<' '<<j<<' '<<fac[n-i]*j<<endl;
        return fac[n-i] * j % mod;
    }
    ll &ans = f[i][j];
    if(ans!=-1) return f[i][j];
    ans = 0;
    int x = 0, y = 0;
    for(int k=i+1;k<=n;k++){
        if(a[k]<=j){
//            cout<<i<<','<<j<<','<<k<<','<<calc(k,j%a[k])*push(n-k,y)%mod*push(n-i-x,x)%mod<<endl;
            add(ans,calc(k,j%a[k])*push(n-k,y)%mod*push(n-i-x,x)%mod);
        }
        if(a[k]<=j) y++;
        else x++;
    }
//    cout<<i<<' '<<j<<' '<<ans<<endl;
    return ans;
}
int main(){
    fac[0] = 1; for(int i=1;i<N;i++) fac[i] = fac[i-1] * i % mod;
    inv[N-1] = qpow(fac[N-1],mod-2);
    for(int i=N-2;i>=0;i--) inv[i] = inv[i+1] * (i + 1) % mod;
    ios::sync_with_stdio(0);
    int x; cin>>n>>x;
    for(int i=1;i<=n;i++) cin>>a[i];
    sort(a+1,a+1+n,greater<int>());
    memset(f,-1,sizeof(f));
    cout<<calc(0,x)<<endl;
}


#include <bits/stdc++.h>

using namespace std;

template <typename A, typename B>
string to_string(pair<A, B> p);

template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p);

template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p);

string to_string(const string& s)
{
    return '"' + s + '"';
}

string to_string(const char* s)
{
    return to_string((string) s);
}

string to_string(bool b)
{
    return (b ? "true" : "false");
}

string to_string(vector<bool> v)
{
    bool first = true;
    string res = "{";
    for (int i = 0; i < static_cast<int>(v.size()); i++)
    {
        if (!first)
        {
            res += ", ";
        }
        first = false;
        res += to_string(v[i]);
    }
    res += "}";
    return res;
}

template <size_t N>
string to_string(bitset<N> v)
{
    string res = "";
    for (size_t i = 0; i < N; i++)
    {
        res += static_cast<char>('0' + v[i]);
    }
    return res;
}

template <typename A>
string to_string(A v)
{
    bool first = true;
    string res = "{";
    for (const auto &x : v)
    {
        if (!first)
        {
            res += ", ";
        }
        first = false;
        res += to_string(x);
    }
    res += "}";
    return res;
}

template <typename A, typename B>
string to_string(pair<A, B> p)
{
    return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}

template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p)
{
    return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ")";
}

template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p)
{
    return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ", " + to_string(get<3>(p)) + ")";
}

void debug_out()
{
    cerr << endl;
}

template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T)
{
    cerr << " " << to_string(H);
    debug_out(T...);
}

#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

const long long INF = 1e18;

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    vector<long long> a(n + 1);
    for (int i = 1; i <= n; i++)
    {
        cin >> a[i];
    }
    vector<long long> dp1(n + 1, -INF), dp0(n + 1, -INF);

    dp0[1] = a[1];
    dp1[1] = -a[1];
    for (int i = 2; i < n; i++)
    {
        dp0[i] = max(dp0[i - 1] + a[i], dp1[i - 1] - a[i]);
        dp1[i] = max(dp0[i - 1] - a[i], dp1[i - 1] + a[i]);
    }
    long long ans = max(dp0[n - 1] + a[n], dp1[n - 1] - a[n]);
    cout << ans;
    return 0;
}

#include <iostream>
#include <algorithm>

using namespace std;

static const int N = 100;
#define rep(i,a) for(int i = 0 ; i < a ; i ++)
#define loop(i,a,b) for(int i = a ; i < b ; i ++)
int main(void){
	int n,p[N+1],m[N+1][N+1];
	cin>>n;

	loop(i,1,n+1){
		cin>>p[i-1]>>p[i];
	}

	loop(i,1,n+2)m[i][i] = 0;

	loop(l,2,n+1){
		loop(i,1,n-l+2){
			int j = i + l - 1;
			m[i][j] = (1<<21);
			loop(k,i,j){
				m[i][j] = min(m[i][j],m[i][k] + m[k+1][j] + p[i-1]*p[k]*p[j]);
			}
		}
	}
	cout << m[1][n] << endl;
}


#include <bits/stdc++.h>
using namespace std;

int main() {
  double rate;
  int pfm,hrate;
  cin>>rate>>hrate;
  cout<<hrate*2-rate<<endl;
}

#include<iostream>
using namespace std;
int main(){
	int a,i,j,k;
	int s=0;
	while(cin>>a){
		for(i=a;i<600;i+=a){
			s+=i*i*a;
		}
		cout<<s<<endl;
		s=0;
	}
	return 0;
}


#include<iostream>
#include<cstdio>
#include<string>
#include<vector>
#include<map>
#include<queue>
#include<algorithm>

using namespace std;
const int INF=11;

int w,h;

int field[22][22];
int sx,sy;
int gx,gy;
int ans=INF;
int hx[4]={1,-1,0,0,},hy[4]={0,0,1,-1,};

void dfs(int field2[22][22],int x,int y,int mx,int my,int c){
	int a;
	if(c>10)return;
	if(c>ans)return;
	if(x>0 && x<=w && y>0 && y<=h);else return;
	if(field2[x][y]==3){
		if(ans>c)ans=c;
		return;
	}
	if(field2[x+mx][y+my]==1){
		field2[x+mx][y+my]=0;
		for(a=0;a<4;a++){
			if(field2[x+hx[a]][y+hy[a]]!=1)dfs(field2,x,y,hx[a],hy[a],c+1);
		}
		field2[x+mx][y+my]=1;
	}else dfs(field2,x+mx,y+my,mx,my,c);
	return;
}

int main(void){
	int a,b;
	while(1){
		for(b=0;b<21;b++){
			for(a=0;a<21;a++){
				field[a][b]=0;
			}
		}
		ans=INF;
		sx=0;
		sy=0;
		gx=0;
		gy=0;
		cin >> w >> h;
		if(w==0 && h==0)break;
		for(b=1;b<=h;b++){
			for(a=1;a<=w;a++){
				cin >> field[a][b];
				if(field[a][b]==2)sx=a,sy=b,field[a][b]=0;
				if(field[a][b]==3)gx=a,gy=b;

			}
		}
		for(a=0;a<4;a++){
			if(field[sx+hx[a]][sy+hy[a]]!=1)dfs(field,sx,sy,hx[a],hy[a],1);
		}
		printf("%d\n",ans<=10?ans:-1);
	}
	return 0;
}

#include<cstdio>
#include<algorithm>
using namespace std;
int main(void)
{
	int n,y;
	int i,j,flg=0;
	scanf("%d %d",&n,&y);
	for(i=0;i<=n;i++){
		for(j=0;j<=n;j++){
			if(n-(i+j)<0) {
				break;
			}
			if(i+j+n-(i+j)==n&&y==i*10000+j*5000+(n-(i+j))*1000){
				flg=1;
				break;
			}
		}
		if(flg==1) break;
	}
	if(flg==1){
		printf("%d %d %d\n",i,j,n-(i+j));
	}
	else if(flg==0||flg==2){
		printf("-1 -1 -1\n");
	}
	return 0;
}


#include <iostream>
#include <cstdio>
#include <vector>
#include <utility>
#include <queue>
#include <functional>
#define N 101
#define INF 200000000
using namespace std;

int main(void){
	int a,b,c,d;
	int n,m;
	while(cin>>n>>m,n||m){
		int dp[m+1][m+1];
		int dp1[m+1][m+1];
		for(int i=1;i<=m;i++){
			for(int j=1;j<=m;j++){
				if(i==j)dp[i][j]=dp1[i][j]=0;
				else dp[i][j]=dp1[i][j]=INF;
			}
		}

		for(int i=0;i<n;i++){
			cin>>a>>b>>c>>d;
			dp[b][a]=c;
			dp[a][b]=c;
			dp1[b][a]=d;
			dp1[a][b]=d;
		}

		for(int k=1;k<=m;k++){
			for(int u=1;u<=m;u++){
				for(int v=1;v<=m;v++){
					dp[u][v]=min(dp[u][v],dp[u][k]+dp[k][v]);
					dp1[u][v]=min(dp1[u][v],dp1[u][k]+dp1[k][v]);
				}
			}
		}

		int k;
		cin>>k;
		while(k--){
			cin>>a>>b>>c;
			if(c) cout<<dp1[a][b]<<endl;
			else cout<<dp[a][b]<<endl;
		}
	}
	return 0;
}

#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>

using namespace std;

bool cmp(pair<double, string> p, pair<double, string> q)
{
    return (p.first > q.first) || (p.first == q.first && p.second < q.second);
}

int main()
{
    int n;

    while (cin >> n) {
        if (!n)
            break;

        vector<pair<double, string> > crop;

        for (int i = 0; i < n; i++) {
            int p, a, b, c, d, e, f, s, m;
            string l;
            double income = 0.0;

            cin >> l >> p >> a >> b >> c >> d >> e >> f >> s >> m;

            income = (double)(m * s * f - p) / ((a + b + c) + (d + e) * m);

            crop.push_back(pair<double, string>(income, l));
        }
        sort(crop.begin(), crop.end(), cmp);

        for (int i = 0; i < crop.size(); i++)
            cout << crop[i].second << endl;
        cout << "#\n";
    }

    return 0;
}


#include <iostream>
#include<algorithm>
#include<string>
#include <cmath>
#include <vector>
#include <map>
#include <cstdio>
#include <iomanip>
#pragma region Macros
#define int long long
#define double long double
constexpr int MOD = 1000000007;
constexpr double PI = 3.14159265358979323846;
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<=n;i++)
#define LAST(x) x[x.size()-1]
#define ALL(x) (x).begin(),(x).end()
#define swap(a,b) (a += b,b = a - b,a -= b)
#define CEIL(a,b) ((a+b-1)/b)
int FACT(int a) {
	if (a == 0)
		return 1;
	else
		return a * FACT(a - 1);
}
int nPr(int n, int r) {
	int s = n-r+1;
	int sum = 1;
	for(int i =s;i<=n;i++)
		sum *= i;
	return sum;
}
//int nCr1(int n, int r)
//int nCr2(int n, int r)
int GCD(int a, int b) // assuming a,b >= 1
{
	if (a < b)
		swap(a, b);
	if (b == 0)
		return a;
	if (a % b == 0)
		return b;
	return GCD(b, a % b);
}
int LCM(int a, int b) // assuming a,b >= 1
{
	return  a * b / GCD(a, b);
}
double LOG(int a, int b) {
	return log(b) / log(a);
}
inline bool BETWEEN(int x, int min, int max) {
	if (min <= x && x <= max)
		return true;
	else
		return false;
}

using namespace std;
#pragma endregion
signed main() {
	int K, N;
	cin >> K >> N;
	cout << K - N + 1;
}

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
#define rep(i,N) for(ll (i)=0;(i)<(N);(i)++)
const int mod = 1000000007;

int main(){
  int n, k;
  cin >> n >> k;
  k--;
  cout << n - k << endl;
}


#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <bitset>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <numeric>
#include <iostream>
#include <iomanip>
#include <string>
#include <chrono>
#include <random>
#include <cmath>
#include <cassert>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <functional>
#include <sstream>

using namespace std;

int main(int argc, char** argv) {
    ios::sync_with_stdio(false);
    cin.tie(0);

    map<int,int> cnts;
    cnts[0] += 1;

    int n, m;
    cin >> n >> m;

    long long res = 0;
    long long sum = 0;
    for (int i = 0; i < n; ++i) {
        long long x;
        cin >> x;
        sum += x;
        res += cnts[sum % m];
        cnts[sum % m] += 1;
    }

    cout << res << '\n';

    return 0;
}

#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <queue>
#include <utility>
#include <map>
#include <numeric>
#include <iomanip>
#define ll long long
#define pi 3.14159265358979323846
using namespace std;
using p = pair<ll, ll>;
ll dx[4] = {-1, 0, 1, 0};
ll dy[4] = {0, 1, 0, -1};
/*　BFS
 vector<vector<ll>> g(n+1);
    for(ll i = 0; i < m; i++){
        ll a, b;
        cin >> a >> b;
        g[a].push_back(b);
        g[b].push_back(a);
    }
    vector<ll> dist(n+1, -1);
    queue<ll> que;
    que.push(1);
    dist[1] = 0;
    while(!que.empty()){
        ll v = que.front();
        que.pop();
        for(ll nv : g[v]){
            if(dist[nv]!=-1) continue;
            dist[nv] = dist[v]+1;
            que.push(nv);
        }
    }
*/

int main(){
    ll n, m;
    cin >> n >> m;
    ll a[n];
    map<ll, ll> I{};
    for(ll i = 0; i < n; i++){
        cin >> a[i];
        a[i] %= m;
        I[a[i]]++;
    }
    ll sum[n+1];
    sum[0] = a[0]%m;
    for(ll i = 1; i < n; i++){
        sum[i] = sum[i-1]+a[i];
        sum[i]%=m;
    }
    sort(sum, sum+n);
    sum[n] = -11111111111;
    ll ans = 0;
    ll count = 1;
    for(ll i = 0; i < n; i++){
       // cout << sum[i] << endl;
        if(sum[i]==0) ans++;
        if(sum[i]==sum[i+1]) count++;
        else {
            ans += count*(count-1)/2;
            count = 1;
        }
    }
    ans += count*(count-1)/2;
    cout << ans << endl;
    return 0;
}


#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <unordered_map>
#include <queue>
#include <algorithm>

#include <bits/stdc++.h>
#include <cmath>
#include <limits>

using namespace std;
typedef long long LL;
using Graph = vector<vector<int>>;

static long long INF = (1LL<<62);

int main(int argc, char* argv[]){
	cin.tie(0);
	ios::sync_with_stdio(false);

	int A, B, C;
	cin >> A >> B >> C;

	if(A < B){
		if(A < C && C < B){
			printf("Yes\n");
		}
		else{
			printf("No\n");
		}
	}
	else{
		if(B < C && C < A){
			printf("Yes\n");
		}
		else{
			printf("No\n");
		}
	}
	return 0;
}

#include <bits/stdc++.h>
#include <math.h>

using namespace std;

long long inf=1000000007;

int main(){
	int a,b,c;
	cin>>a>>b>>c;

	while(a!=b){
		if(a==c){
			cout<<"Yes"<<endl;
			return 0;
		}

		if(a<b) a++;
		else a--;
	}

	cout<<"No"<<endl;

	return 0;
}


#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i<n;i++)
#define inf 1e9+7
using namespace std;
typedef long long ll;
const double pi=acos(-1);

ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

int main(){
    int n;
    string s;
    cin >> n >> s;
    ll r=0,g=0,b=0;
    for(int i=0;i<n;i++){
        if(s[i]=='R') r++;
        else if(s[i]=='G') g++;
        else b++;
    }
    ll sum=r*g*b;
    for(int i=0;i<n-2;i++){
        for(int j=i+2;j<n;j++){
            if((i+j)%2!=0) continue;
            if(s[i]!=s[(i+j)/2] && s[i]!=s[j] && s[j]!=s[(i+j)/2]) sum--;
        }
    }
    cout << sum << endl;
}

#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define rep(i,n) for (int i = 0; i < (n); i++)
typedef pair<int,int> P;
const int INF = 100000000;
typedef long long ll;

int W,H;
int sy, sx, gy, gx;

int dx[4] = {1,-1,0,0};
int dy[4] = {0,0,1,-1};

bool movable(vector<vector<char>> &c, vector<vector<int>> &mat, int h, int w, int hb, int wb) {
  if ((h<0) || (h>=H) || (w<0) || (w>=W)) {
    return false;
  }
  else if (mat[h][w]!=INF || (c[h][w]==c[hb][wb])) {
    return false;
  }
  else {
    return true;
  }
}

ll bfs(vector<vector<char>> &c, vector<vector<int>> &mat, pair<int,int> &q) {
  ll k,s;
  s=0;
  k = 1;
  queue<P> que;
  que.push(q);

  if (mat[q.first][q.second] != INF) return 0;
  else (mat[q.first][q.second] = 0);

  while(que.size()) {
    P p = que.front();
    que.pop();

    rep(i,4){
      if (movable(c,mat,p.first+dy[i],p.second+dx[i],p.first,p.second)) {
        que.push(P(p.first+dy[i],p.second+dx[i]));
        mat[p.first+dy[i]][p.second+dx[i]]=mat[p.first][p.second]+1;
        if (c[p.first+dy[i]][p.second+dx[i]]=='.') s++;
        else k++;
      }
    }
  }
  return k*s;
}

int main() {
  cin >> H >> W;

  vector<vector<char>> c(H,vector<char> (W));
  vector<pair<int,int>> P;
  rep(h,H) {
      string s;
      cin >> s;
    rep(w,W) {
      c[h][w] = s[w];
      if (s[w]=='#') {
          P.push_back(make_pair(h,w));
      }
    }
  }
  vector<vector<int>> mat(H,vector<int> (W, INF));
  ll ans = 0;
  for (auto p: P) {
    ll tmp = bfs(c,mat,p);
    ans += tmp;

  }
    cout << ans << endl;
}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;

string c(ll n);
int main() {
  ll n;
  cin >> n;
  cout << c(n);
}

string c(ll n) {
  // n >= 1
  string ans = "";
  while(n) {
    n--;
    ans += (char)('a' + (n % 26));
    n/=26;
  }
  reverse(ans.begin(), ans.end());
  return ans;
}

#include<bits/stdc++.h>
using namespace std;

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

int po[22];

int dfs(int i,int dif,int L){
    if(i==L/2){
        return dif==0;
    }

    int u=po[L-1-i]-po[i];

    int x;
    if(dif>=0){
        x=(dif+u-1)/u;
    }
    else{
        x=dif/u;
    }

    int ret=0;
    for(int uku=0;uku<2;uku++,x--){
        if(x<-9||9<x)continue;
        int tmp=dfs(i+1,dif-u*x,L);

        int k=10-abs(x);
        if(i==0&&x>=0)k--;
        ret+=tmp*k;
    }

    return ret;
}

signed main(){
    po[0]=1;
    for(int i=1;i<22;i++)po[i]=po[i-1]*10;
    int D;cin>>D;
    int ans=0;
    for(int i=2;i<=18;i++){
        int w;
        if(i&1)w=10;
        else w=1;

        ans+=w*dfs(0,D,i);
    }
    cout<<ans<<endl;
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define repr(i, n) REPR(i, n, 0)
#define REPR(i, s, e) for(int i=(int)(s-1); i>=(int)(e); i--)
#define pb push_back
#define all(r) r.begin(),r.end()
#define rall(r) r.rbegin(),r.rend()
#define fi first
#define se second

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const ll INF = 1e9;
const ll MOD = 1e9 + 7;
const double EPS = 1e-8;

template<typename T> T chmax(T& a, const T& b){return a = (a > b ? a : b);}
template<typename T> T chmin(T& a, const T& b){return a = (a < b ? a : b);}

ll modPow(ll x, ll n) {
    ll ret = 1;
    while(n) {
        if(n&1LL) (ret *= x) %= MOD;
        n >>= 1;
        (x *= x) %= MOD;
    }
    return ret;
}

ll dp[41][(1<<17)+10];

int main(){
    int n;
    vi v(3);
    cin >> n;
    rep(i, 3) cin >> v[i];
    int sum_v = v[0] + v[1] + v[2];
    dp[0][0] = 1;
    auto check = [&](int mask) {
        bool f = true;
        f &= (mask >>=(v[2]-1)) & 1;
        f &= (mask >>=v[1]) & 1;
        f &= (mask >>=v[0]) & 1;
        return f;
    };
    auto pop_mask = [&](int mask) {
        if(mask == 0) return 0;
        bool f = true;
        repr(i, sum_v) {
            if(mask & (1<<i)) {
                if(f) {
                    mask -= (1<<i);
                    f = false;
                    break;
                }
            }
        }
        return mask;
    };
    auto getSize = [&](int mask) {
        if(mask == 0) return 0;
        repr(i, sum_v) {
            if(mask&(1<<i)) {
                return i+1;
            }
        }
        return 0;
    };
    auto push_mask = [&](int mask, int add) {
        if(add > sum_v) return 0;
        while(getSize(mask)+add > sum_v) {
            mask = pop_mask(mask);
        }
        mask <<= add;
        mask |= 1<<(add-1);
        return mask;
    };
    rep(i, n) rep(mask, 1<<sum_v) {
        REP(k, 1, 11) {
            int nxt = push_mask(mask, k);
            if(check(mask) || check(nxt)) continue;
            (dp[i+1][nxt] += dp[i][mask]) %= MOD;
        }
    }
    ll sum = 0LL;
    rep(mask, 1<<sum_v) (sum += dp[n][mask]) %= MOD;
    ll ans = modPow(10, n);
    (ans += MOD - sum) %= MOD;
    cout << ans << endl;
    return 0;
}

#include <iostream>
#include <cstdio>
#define int long long
using namespace std;
const int mod=1000000007;
int f[42][1<<18],n,x,y,z,i,j,k,lim,tmp;
signed main()
{
	cin>>n>>x>>y>>z;
	tmp=(1<<(x+y+z-1));
	tmp|=(1<<(y+z-1));
	tmp|=(1<<(z-1));
	lim=(1<<(x+y+z))-1;
	f[0][0]=1;
	for(i=1;i<=n;i++){
		for(j=0;j<=lim;j++){
			if(f[i-1][j]==0) continue;
			for(k=1;k<=10;k++){
				int now=((j<<k)|(1<<(k-1)));
				now&=lim;
				if((now&tmp)!=tmp) f[i][now]=(f[i][now]+f[i-1][j])%mod;
			}
		}
	}
	int ans=1;
	for(i=1;i<=n;i++) ans=ans*10%mod;
	for(i=0;i<=lim;i++) ans=(ans-f[n][i]+mod)%mod;
	cout<<ans<<endl;
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i=0; i<(int)(n); i++)
#define all(x) x.begin(), x.end()
#define mod 1000000007
typedef long long ll;

int main(){
  int n;
  cin >> n;
  vector<tuple<ll, ll, ll>> vec;
  rep(i, n){
    ll a, b;
    cin >> a >> b;
    vec.push_back(make_tuple(a+b, a, b));
  }
  sort(all(vec), greater<tuple<ll, ll, ll>>());
  ll sumA=0, sumB=0;
  rep(i, n){
   	 if(i%2==0){
       sumA += get<1>(vec[i]);
     }else{
       sumB += get<2>(vec[i]);
     }
  }
  cout << sumA-sumB << endl;
  return 0;
}

#include <bits/stdc++.h>
#define ll  long long
#define ull unsigned long long
using namespace std;
#define  inf 1e18+18
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL)
#define mod 1000000007
#define  f1(i,n) for(i=1;i<=n;i++)
#define f0(i,n)  for(i=0;i<n;i++)
#define w(x)   while(x--)
const int maxn=40000;
#define  pq priority_queue
#define  ff first
#define  ss second
#define pb  push_back
#define lb lower_bound
int main()
{
	int i,j,k,l,m,n;
	string s;
	cin>>n;
	int a[n];
	for(i=0;i<n;i++)
		cin>>a[i];
	l=0;
	sort(a,a+n);
	for(i=0;i<n;i++)
	{
		for(j=i+1;j<n;j++)
		{
			for(k=j+1;k<n;k++)
			{
				if(a[i]==a[j]||a[i]==a[k]||a[j]==a[k])
					continue;
				if(a[i]+a[j]>a[k])
					l++;
			}
		}
	}
	cout<<l;
}


#include<iostream>
#include<algorithm>
#include<string>
#include<cmath>
#include<vector>
#include<map>
using namespace std;
long long F(long long A){
    long long ta = A;
    long long fa = 0;
    for(int i = 0; i <= 10; i++){
        if(ta <= 0) break;
        ta /= 10;
        fa++;
    }
    return fa;
}
int main() {
    long long N;
    cin >> N;
    long long n = sqrt(N);
    long long min = 10;
    for(int i = 1; i <= n; i++){
        if(N%i == 0){
            long long A = i;
            long long B = N / i;
            long long m;
            if(F(A) > F(B)) m = F(A);
            else m = F(B);
            if(min > m) min = m;
        }
    }
    cout << min << endl;
    return 0;
}

#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG //GCC5.4.1で配列の範囲外アクセスをエラーにする

//cmdで g++ test.cpp とするとコンパイルできる
//制限1秒なら10^6は余裕 10^7は多分間に合う 10^8はよほど単純でないと厳しい
// https://github.com/atcoder/live_library
// cppdbg: test.exeのterminalに標準入力を打てる

#define ALL(x) x.begin(),x.end()
#define get_tp(t,i) get<i>(t)
#define len(x) (ll)(x.size())
#define ub(a,x) (upper_bound(ALL(a),x)-a.begin())
#define lb(a,x) (lower_bound(ALL(a),x)-a.begin())
typedef long long ll; //long long
typedef pair<int,int> pii; //pair<int,int>
typedef pair<long long,long long> pllll; //pair<ll,ll>
typedef vector<int> vi; //vector<int>
typedef vector<vector<int>> vvi; //vector<vector<int>>
typedef vector<ll> vll; //vector<long long>
typedef vector<vector<ll>> vvll; //vector<vector<long long>>
typedef priority_queue<ll, vector<ll>, greater<ll> > gpq; //逆順priority_queue
typedef priority_queue<ll> pq;

//const int MOD=998244353;
const int MOD=1000000007; //10^9+7
const long double PI=3.1415926535897932;

int main(){
    string S;cin>>S;
    int L=S.size();
    if(S[0]!='A'){
        cout<<"WA"<<endl;return 0;
    }
    int c_count=0;
    for(int i=2;i<L-1;i++){
        if(S[i]=='C')c_count++;
    }
    if(c_count!=1){
        cout<<"WA"<<endl;return 0;
    }
    for(int i=1;i<L;i++){
        if((S[i]<'a'||'z'<S[i]) && S[i]!='C'){
            cout<<"WA"<<endl;return 0;
        }
    }
    cout<<"AC"<<endl;return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define REP(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) REP(i, 0, n)
#define rrep(i, n) for (int i = (int)(n-1); i >= 0; i--)
#define sz(x) int(x.size())
#define bitsz(x) int(__builtin_popcount(x))
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define pb(x) push_back(x)
#define INF 2e9
#define LINF 1e18
#define mod 1000000007
template<class T> inline bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T &a, const T &b) { if (a > b) { a = b; return 1; } return 0; }
template < typename T > inline string toString( const T &a ) { ostringstream oss; oss << a; return oss.str(); };
typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
const int di[4] = {1,0,-1,0};
const int dj[4] = {0,1,0,-1};

int main() {
    int n; cin >> n;
    vector<int> a(n);
    rep(i,n) cin >> a[i];
    ll ans = 0;
    for (int i=1; i<n; i++) {
        if (a[i-1]<=a[i]) continue;
        ans += a[i-1]-a[i];
        a[i] += a[i-1]-a[i];
    }
    cout << ans << endl;
}

#include<cstdint>
#include<limits>
#include<cstdbool>
#include<cmath>
#include<iostream>
#include<vector>
#include<array>
#include<list>
#include<string>
#include<sstream>
#include<algorithm>

int main(){
	int n,h,w;
	std::cin>>n>>h>>w;
	std::cout<<1+(n-h)+(n-w)+(n-h)*(n-w);
}


#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
typedef vector<double> VD;
typedef vector<VD> VVD;

template<typename T> void chmin(T &a, T b) { if (a > b) a = b; }
template<typename T> void chmax(T &a, T b) { if (a < b) a = b; }

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }

const ll mod = 1e9 + 7;

ll add(ll x, ll y){
    return (x+y)%mod;
}

ll mul(ll x, ll y){
    return (x%mod)*(y%mod)%mod;
}

ll powll(ll x, ll y){
    x %= mod;
    ll res = 1LL;
    while(y){
        if (y & 1LL)
            res *= x;
        res %= mod;
        x = (x*x) % mod;
        y >>= 1LL;
    }
    return res;
}

ll naive(VI a, int x){
    // cout << "naive" << endl;
    int n = a.size();
    VVL dp(n + 1, VL(2));
    dp[0][0] = 1;
    int y = 0;
    REP(i,n){
        y ^= a[i];
        if (y == x){
            REP(j,i+1) dp[i+1][1] += dp[j][0];
        }
        if (y == 0){
            REP(j,i+1) dp[i+1][0] += dp[j][1];
        }
        // cout << dp[0] << " " << dp[1] << endl;
    }
    // REP(i,n+1) cout << dp[i][0] << " " << dp[i][1] <<endl;

    return dp[n][0];
}

ll calc(VL a, VL b){
    int n = a.size();
    if (n == 1) return a[0];
    VL dp(n);
    dp[0] = a[0];
    ll sum = dp[0], tmp = 0;
    REP(i,n-1){
        tmp = (tmp + b[i] * sum) % mod;
        dp[i + 1] = ((tmp + 1) * a[i + 1]) % mod;
        sum = (sum + dp[i + 1]) % mod;
    }
    ll ret = 0;
    REP(i,n) ret = (ret + dp[i]) % mod;
    return ret;
}

int main() {
    int n;
    cin >> n;
    VI a(n);
    int x = 0;
    REP(i,n){
        a[i] = in();
        x ^= a[i];
    }

    if (x != 0){
        VL dp(2);
        dp[0] = 1;
        int y = 0;
        REP(i,n){
            y ^= a[i];
            if (y == x){
                dp[1] = (dp[1] + dp[0]) % mod;
            }
            if (y == 0){
                dp[0] = (dp[0] + dp[1]) % mod;
            }
        }
        cout << dp[0] << endl;
        return 0;
    }

    ll cnt = 0;
    int j = 0;
    map<int, VL> mpc, mpl;
    map<int, int> last;
    REP(i,n){
        x ^= a[i];
        if (x == 0){
            map<int, ll> tmp;
            int p = 0;
            FOR(k,j,i-1){
                p ^= a[k];
                tmp[p]++;
            }
            // FOR(k,j,i){
            //     cout << a[k] << " ";
            // }
            // cout << endl;
            for (auto hoge : tmp){
                int p = hoge.first;
                ll c = hoge.second;
                mpc[p].push_back(c);
                if (last.count(p)){
                    mpl[p].push_back(cnt - last[p]);
                }
                last[p] = cnt;
            }
            cnt++;
            j = i + 1;
        }
    }

    // cout << cnt << " " << powll(2, cnt - 1) << endl;

    ll ans = powll(2, cnt - 1);
    for (auto tmp : mpc){
        int x = tmp.first;
        // cout << "x" << x << endl;
        // for (int c : mpc[x]) cout << c << " ";
        // cout << endl;
        // for (int l : mpl[x]) cout << l << " ";
        // cout << endl;
        // cout << naive(a, x) << endl;

        ans = (ans + calc(mpc[x], mpl[x])) % mod;
    }
    cout << ans << endl;
    return 0;
}

#include <bits/stdc++.h>

using namespace std;

#define INF 1001000100010001000
#define MOD 1000000007
#define EPS 1e-10
#define int long long
#define rep(i, N) for (int i = 0; i < N; i++)
#define Rep(i, N) for (int i = 1; i < N; i++)
#define For(i, a, b) for (int i = (a); i < (b); i++)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define pii pair<int, int>
#define vi vector<int>
#define vvi vector<vi >
#define vb vector<bool>
#define vvb vector<vb >
#define vp vector< pii >
#define all(a) (a).begin(), (a).end()
#define Int(x) int x; cin >> x;
#define int2(x, y) Int(x); Int(y);
#define int3(x, y, z) Int(x); int2(y, z);
#define in(x, a, b) ((a) <= (x) && (x) < (b))
#define fir first
#define sec second
#define ffir first.first
#define fsec first.second
#define sfir second.first
#define ssec second.second
#define Decimal fixed << setprecision(10)

//int dxy[5] = {0, 1, 0, -1, 0};
// cmd

signed main()
{
    std::ios::sync_with_stdio(false);
    std::cin.tie(0);

    Int(n);
    vector<int> data(n);
    for (int i = 0; i < n; i++) {
        cin >> data[i];
    }
    Rep(i, n) data[i] ^= data[i-1];

    vi dp0(1 << 20, 1), dp1(1 << 20, 0), zeros(1 << 20, 0);
    // 始点に 0 があると考えるので全ての x について初期0数1個
    int zero = 0;
    rep(i, n) {
        if (!data[i]) {
            zero++;
        } else {
            (dp0[data[i]] += dp1[data[i]] * (zero - zeros[data[i]])) %= MOD; // 0 の累積を求める
            (dp1[data[i]] += dp0[data[i]]) %= MOD; // i 番目の解が求められ、区間の値 k = data[i] の時の解の累積が増える
            zeros[data[i]] = zero;
            //std::cout << dp0[data[i]] << " , " << dp1[data[i]] << std::endl;
        }
    }

    if (data.back()) {
        std::cout << dp0[data.back()] << std::endl;
    } else {
        int ans = 1;
        rep(i, zero-1) ans = (ans * 2) % MOD;
        rep(i, dp1.size()) ans += dp1[i];
        std::cout << ans % MOD << std::endl;
    }

    return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main(){
	string s,t;
	while(getline(cin,s)){t=s;
	for(int i=0;i<26;i++){
		s=t;
		for(int j=0;j<s.size();j++){
			if(s[j]>='a'&&s[j]<='z')for(int k=0;k<i;k++){
				s[j]++;
				if(s[j]>'z')s[j]-=26;
			}
		}
		if((s.find("the")!=s.npos||s.find("this")!=s.npos||s.find("that")!=s.npos))break;
	}
	cout<<s<<endl;}
}

#include <bits/stdc++.h>
using namespace std;

//#define int long long
typedef long long ll;

typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = mod * mod;
const int INF_N = 1e+9;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
#define all(v) (v).begin(),(v).end()
typedef pair<ll, ll> LP;
typedef long double ld;
typedef pair<ld, ld> LDP;
const ld eps = 1e-12;
const ld pi = acos(-1.0);
//typedef vector<vector<ll>> mat;
typedef vector<int> vec;

//繰り返し二乗法
ll mod_pow(ll a, ll n, ll m) {
	ll res = 1;
	while (n) {
		if (n & 1)res = res * a%m;
		a = a * a%m; n >>= 1;
	}
	return res;
}

struct modint {
	ll n;
	modint() :n(0) { ; }
	modint(ll m) :n(m) {
		if (n >= mod)n %= mod;
		else if (n < 0)n = (n%mod + mod) % mod;
	}
	operator int() { return n; }
};
bool operator==(modint a, modint b) { return a.n == b.n; }
modint operator+=(modint &a, modint b) { a.n += b.n; if (a.n >= mod)a.n -= mod; return a; }
modint operator-=(modint &a, modint b) { a.n -= b.n; if (a.n < 0)a.n += mod; return a; }
modint operator*=(modint &a, modint b) { a.n = ((ll)a.n*b.n) % mod; return a; }
modint operator+(modint a, modint b) { return a += b; }
modint operator-(modint a, modint b) { return a -= b; }
modint operator*(modint a, modint b) { return a *= b; }
modint operator^(modint a, int n) {
	if (n == 0)return modint(1);
	modint res = (a*a) ^ (n / 2);
	if (n % 2)res = res * a;
	return res;
}

//逆元(Eucledean algorithm)
ll inv(ll a, ll p) {
	return (a == 1 ? 1 : (1 - p * inv(p%a, a)) / a + p);
}
modint operator/(modint a, modint b) { return a * modint(inv(b, mod)); }

const int max_n = 1 << 18;
modint fact[max_n], factinv[max_n];
void init_f() {
	fact[0] = modint(1);
	for (int i = 0; i < max_n - 1; i++) {
		fact[i + 1] = fact[i] * modint(i + 1);
	}
	factinv[max_n - 1] = modint(1) / fact[max_n - 1];
	for (int i = max_n - 2; i >= 0; i--) {
		factinv[i] = factinv[i + 1] * modint(i + 1);
	}
}
modint comb(int a, int b) {
	if (a < 0 || b < 0 || a < b)return 0;
	return fact[a] * factinv[b] * factinv[a - b];
}
using mP = pair<modint, modint>;

int dx[4] = { 0,1,0,-1 };
int dy[4] = { 1,0,-1,0 };

void solve() {
    int H, W, A, B; cin >> H >> W >> A >> B;
    rep(i, H){
        rep(j, W){
            if(i<B){
                if(j<A) cout << 1;
                else cout << 0;
            }else{
                if(j<A) cout << 0;
                else cout << 1;
            }
        }
        cout << endl;
    }
}

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  //cout << fixed << setprecision(10);
  //init_f();
  //init();
  //int t; cin >> t; rep(i, t)solve();
  solve();
//   stop
    return 0;
}


#include <iostream>
using namespace std;

int main() {
  int A, B, C, D, E, F;
  cin >> A >> B >> C >> D >> E >> F;

  int sum = 0;

  if (A <= B && A <= C && A <= D) sum += B + C + D;
  else if (B <= A && B <= C && B <= D) sum += A + C + D;
  else if (C <= A && C <= B && C <= D) sum += A + B + D;
  else sum += A + B + C;

  if (E <= F) sum += F;
  else sum += E;

  cout << sum << endl;

  return 0;
}

//
//  main.cpp
//  testing
//
//  Created by 伊藤大騎 on 2019/01/07.
//  Copyright © 2019 HamamatsuJOHOKU. All rights reserved.
//
/*
 科目選択 (Selecting Subjects)

 JOI 君は物理，化学，生物，地学，歴史，地理の 6 科目のテストを受けた． それぞれのテストは 100 点満点で採点された．
 JOI 君は物理，化学，生物，地学の 4 科目から 3 科目を選択し，歴史，地理の 2 科目から 1 科目を選択する．
 テストの合計点が最も高くなるように科目を選ぶとき， JOI 君の選んだ科目のテストの合計点を求めよ．

 入力は 6 行からなり，1 行に 1 つずつ整数が書かれている．
 1 行目には JOI 君の物理のテストの点数 A が書かれている．
 2 行目には JOI 君の化学のテストの点数 B が書かれている．
 3 行目には JOI 君の生物のテストの点数 C が書かれている．
 4 行目には JOI 君の地学のテストの点数 D が書かれている．
 5 行目には JOI 君の歴史のテストの点数 E が書かれている．
 6 行目には JOI 君の地理のテストの点数 F が書かれている．
 書かれている整数 A, B, C, D, E, F はすべて 0 以上 100 以下である．

 出力
 JOI 君が選んだ科目のテストの合計点を 1 行で出力せよ．

 入出力例

 入力例 1    入力例 2
 100        15
 34         21
 76         15
 42         42
 10         15
 0          62

 出力例 1    出力例 2
 228        140

 入出力例 1 では，JOI 君が物理，生物，地学，歴史の 4 科目を選ぶとき，テストの合計点が最高になる．
 物理，生物，地学，歴史の点数はそれぞれ 100, 76, 42, 10 なので，選んだ科目のテストの合計点は 228 である．

 入出力例 2 では，JOI 君が化学，生物，地学，地理の 4 科目を選ぶとき，テストの合計点が最高になる．
 化学，生物，地学，地理の点数はそれぞれ 21, 15, 42, 62 なので，選んだ科目のテストの合計点は 140 である．

 入出力例 2 では，JOI 君が物理，化学，地学，地理の 4 科目を選ぶ場合でも，選んだテストの合計点は 140 である．

 */

#include <iostream>
#include <algorithm>

using namespace std;
int main (){

    int hairetsu[6]={0},ans=0,maxim=0;

    for (int i=0;i<6;i++){
        cin>>hairetsu[i];
    }

    for (int i=0;i<3;i++){
        for (int j=0;j<4;j++){
            if (maxim<hairetsu[j]){
                maxim=hairetsu[j];
            }
        }

        ans+=maxim;

        for (int j=0;j<4;j++){
            if (hairetsu[j]==maxim){
                hairetsu[j]=0;
                maxim=0;
            }
        }
    }
    ans+=max(hairetsu[4],hairetsu[5]);

    cout<<ans<<endl;

return 0;
}


// J'aime
// Chemise Blanche

#include <bits/stdc++.h>
using namespace std;

#define int long long

#define ii pair<int,int>
#define fi first
#define sc second

#define all(x) (x).begin(),(x).end()
#define dbg(x) cerr << __LINE__ << " > " << #x << " = " << (x) << endl

void MAIN() {
  int n, k;
  cin >> n >> k;
  vector<int> a(n);
  for (auto &i : a) cin >> i;
  sort(all(a), greater<int>());
  int ans = 0;
  for (int i = 0; i < k; i++) {
    ans += a[i];
  }
  cout << ans << '\n';
}

signed main() {
#ifdef _DEBUG
  // freopen("in" , "r", stdin );
  // freopen("out", "w", stdout);
#endif
  ios::sync_with_stdio(0); cin.tie(0);
  int T = 1;
  // cin >> T;
  while (T--) MAIN();
}

#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;

int main() {
    int K, X; cin >> K >> X;
    int now = X-K+1;
    while(now <= X+K-1){
        cout << now << endl;
        now++;
    }

    return 0;
}


#include <bits/stdc++.h>
#define ADD(a, b) a = (a + ll(b)) % mod
#define MUL(a, b) a = (a * ll(b)) % mod
#define MAX(a, b) a = max(a, b)
#define MIN(a, b) a = min(a, b)
#define rep(i, a, b) for(int i = int(a); i < int(b); i++)
#define rer(i, a, b) for(int i = int(a) - 1; i >= int(b); i--)
#define all(a) (a).begin(), (a).end()
#define sz(v) (int)(v).size()
#define pb push_back
#define sec second
#define fst first
#define debug(fmt, ...) Debug(__LINE__, ":", fmt, ##__VA_ARGS__)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<int, pi> ppi;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> mat;
typedef complex<double> comp;
void Debug() {cout << '\n'; }
template<class FIRST, class... REST>void Debug(FIRST arg, REST... rest){
	cout<<arg<<" ";Debug(rest...);}
template<class T>ostream& operator<<(ostream& out,const vector<T>& v) {
	out<<"[";if(!v.empty()){rep(i,0,sz(v)-1)out<<v[i]<<", ";out<<v.back();}out<<"]";return out;}
template<class S, class T>ostream& operator<<(ostream& out,const pair<S, T>& v){
	out<<"("<<v.first<<", "<<v.second<<")";return out;}
const int MAX_N = 200010;
const int MAX_V = 100010;
const double eps = 1e-6;
const ll mod = 1000000007;
const int inf = 1 << 29;
const ll linf = 1LL << 60;
const double PI = 3.14159265358979323846;
///////////////////////////////////////////////////////////////////////////////////////////////////

struct P {
	double x, y; int num;
	P() {}
	P(double x, double y, int num) : x(x), y(y), num(num) {
	}
	P operator+(P p) { return P(x + p.x, y + p.y, 0); }
	P operator-(P p) { return P(x - p.x, y - p.y, 0); }
	double det(const P& p) { return x * p.y - y * p.x; }
	double norm() {
		return sqrt(x * x + y * y);
	}
	bool operator<(const P& p) { return y != p.y ? y < p.y : x < p.x; }
	friend ostream& operator<<(ostream& out, const P& p) {
		out << "(" << p.x << ", " << p.y << ")"; return out;
	}
};

vector<P> convex_hull(vector<P>& ps) {
	int n = sz(ps);
	sort(all(ps));
	int k = 0;
	vector<P> qs(n * 2);
	rep(i, 0, n) {
		while(k > 1 && (qs[k - 1] - qs[k - 2]).det(ps[i] - qs[k - 1]) <= -eps) k--;
		qs[k++] = ps[i];
	}

	for(int i = n - 2, t = k; i >= 0; i--) {
		while(k > t && (qs[k - 1] - qs[k - 2]).det(ps[i] - qs[k - 1]) <= -eps) k--;
		qs[k++] = ps[i];
	}
	qs.resize(k - 1);
	return qs;
}

int N;
double ans[110];

void solve() {
	cin >> N;
	vector<P> ps;
	rep(i, 0, N) {
		int a, b;
		cin >> a >> b;
		ps.pb(P{double(a), double(b), i});
	}
	if(N == 2) {
		cout << "0.5\n0.5\n";
		return;
	}
	auto qs = convex_hull(ps);
	int n = sz(qs);
	rep(i, 0, n) {
		P p = qs[i];
		double angle = 1.0;
		rep(j, 0, n) {
			rep(k, 0, n) {
				if(i == j || j == k || k == i) continue;
				P p1 = qs[j];
				P p2 = qs[k];
				p1 = p1 - p; p2 = p2 - p;
				double tmp = (p1.x * p2.x + p1.y * p2.y) / (p1.norm() * p2.norm());
				// debug(i, j, k, tmp, acos(tmp));
				MIN(angle, (PI - acos(tmp)) / (2 * PI));
			}
		}
		ans[qs[i].num] = angle;
	}
	rep(i, 0, N) {
		cout << ans[i] << "\n";
	}
}

int main() {
#ifndef LOCAL
	ios::sync_with_stdio(false);
    cin.tie(0);
#endif
    cout << fixed;
	cout.precision(20);
	srand((unsigned int)time(NULL));
#ifdef LOCAL
	//freopen("in.txt", "wt", stdout); //for tester
    freopen("in.txt", "rt", stdin);
#endif
	solve();
#ifdef LOCAL
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
	return 0;
}

#include <bits/stdc++.h>
using namespace std;
using ll = long long;

ll solve() {
    ll N;
    cin >> N;
    vector<double> X(N), Y(N);
    for ( int i = 0; i < N; i++ ) {
        cin >> X[i] >> Y[i];
    }
    vector<int> c(N);
    int M = 3e5;
    double pi = acos(0) * 2;
    for ( int k = 0; k < M; k++ ) {
        double t = 2 * pi * k / M;
        int mi;
        double mx = -2e6;
        for ( int i = 0; i < N; i++ ) {
            double x = X[i]*cos(t) - Y[i]*sin(t);
            if ( mx < x ) {
                mx = x;
                mi = i;
            }
        }
        c[mi]++;
    }
    for ( int i = 0; i < N; i++ ) {
        cout << c[i] / (double)M << "\n";
    }
    return 0;
}

int main() {
    solve();
    return 0;
}