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

string str;

int find_str(){
	if(str.find("the",0) != string::npos)
		return 1;

	if(str.find("this",0) != string::npos)
		return 1;

	if(str.find("that",0) != string::npos)
		return 1;

	return 0;
}

int main(){
	int i,j;
	while(getline(cin,str)){
		for(i = 0;i < 26;i++){
			for(j = 0;j < str.size();j++){
			if('a'<=str[j]&&str[j]<='z'){
				if(25<(int)str[j]+1-'a'){
					str[j] = 'a';
				}else{
					str[j] = str[j] + 1;
				}
			}
			}
			if(find_str()){
				cout<<str<<endl;
				break;
			}
		}
	}
	return 0;
}

#include <cstdio>
#include <cstring>
#include <map>
using namespace std;

const int msg_size = 80;
const char int2alp[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'
};

typedef map<char, int> myMap;
myMap alp2int;

int get_length(char *data) {
	for (int i = 0;; i++) {
		if (data[i] == '\0') {
			return i;
		}
	}
}

bool is_match(char *data) {
	for (int i = 0; i < 81; i++) {
		if (data[i] == 't' && data[i+1] == 'h') {
			if (data[i+2] == 'e') {
				return true;
			}
			else if (data[i+2] == 'i' && data[i+3] == 's'){
				return true;
			}
			else if (data[i+2] == 'a' && data[i+3] == 't') {
				return true;
			}
		}
	}
	return false;
}

bool gen_caesar(char *data, int size, int length) {
	char prev[100], back[100];
	prev[length] = back[length] ='\0';
	for (int i = 0; i < length; i++) {
		if (data[i] == ' ' || data[i] == '.' || data[i] == '\n') {
			prev[i] = data[i];
			back[i] = data[i];
		}
		else {
			prev[i] = int2alp[(alp2int[data[i]]+size) % 26];
			back[i] = int2alp[(alp2int[data[i]] >= size) ? alp2int[data[i]]-size : 26-(size-alp2int[data[i]])];
		}
	}
	if (is_match(prev)) {
		printf("%s", prev);
		return true;
	}
	if (is_match(back)) {
		printf("%s", back);
		return true;
	}
	return false;
}

void init_alp2int() {
	alp2int.insert(myMap::value_type('a', 0));
	alp2int.insert(myMap::value_type('b', 1));
	alp2int.insert(myMap::value_type('c', 2));
	alp2int.insert(myMap::value_type('d', 3));
	alp2int.insert(myMap::value_type('e', 4));
	alp2int.insert(myMap::value_type('f', 5));
	alp2int.insert(myMap::value_type('g', 6));
	alp2int.insert(myMap::value_type('h', 7));
	alp2int.insert(myMap::value_type('i', 8));
	alp2int.insert(myMap::value_type('j', 9));
	alp2int.insert(myMap::value_type('k', 10));
	alp2int.insert(myMap::value_type('l', 11));
	alp2int.insert(myMap::value_type('m', 12));
	alp2int.insert(myMap::value_type('n', 13));
	alp2int.insert(myMap::value_type('o', 14));
	alp2int.insert(myMap::value_type('p', 15));
	alp2int.insert(myMap::value_type('q', 16));
	alp2int.insert(myMap::value_type('r', 17));
	alp2int.insert(myMap::value_type('s', 18));
	alp2int.insert(myMap::value_type('t', 19));
	alp2int.insert(myMap::value_type('u', 20));
	alp2int.insert(myMap::value_type('v', 21));
	alp2int.insert(myMap::value_type('w', 22));
	alp2int.insert(myMap::value_type('x', 23));
	alp2int.insert(myMap::value_type('y', 24));
	alp2int.insert(myMap::value_type('z', 25));
}

int main(int argc, char *argv[]) {
	init_alp2int();
	char rcv[100];

	while(NULL != fgets(rcv, 80, stdin)) {
		int length = get_length(rcv);

		for (int i = 0; i < 26; i++) {
			if (gen_caesar(rcv, i, length)) {
				break;
			}
		}
	}
	return 0;
}


#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<iomanip>
using namespace std;

int main(){
long long int n,x,ans=0;
cin>>n>>x;
vector<long long int>a(10000000);
for(int i=0;i<n;i++){
    cin>>a[i];
}
for(int i=0;i<n-1;i++){
    if((a[i]+a[i+1])>x){
        ans+=(a[i]+a[i+1]-x);
        a[i+1]=a[i+1]-(a[i]+a[i+1]-x);
        if(a[i+1]<0){
            a[i]+=a[i+1];
            a[i+1]=0;
        }
    }
}
cout<<ans<<endl;
    return 0;
}

#include <iostream>

using namespace std;

int main () {
  int x, y;
  cin >> x >> y;

  int ans = 0;
  ans += max(4 - x, 0);
  ans += max(4 - y, 0);
  if (x == 1 && y == 1) ans += 4;
  ans *= 100000;

  cout << ans << endl;
}


#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(x) x.begin(), x.end()
using ll = long long;
using namespace std;

int main(){
  string s;
  cin >> s;
  map<char, int> mp;
  rep(i, s.size()){
    mp[s.at(i)]++;
  }

  ll ans = 1;
  for(auto p : mp){
    for(auto p2 : mp){
      if(p2.first <= p.first) continue;
      ans += (ll)p.second * p2.second;
    }
  }
  cout << ans << endl;
  return 0;
}

#include<bits/stdc++.h>

using namespace std;

typedef long long int ll;

const ll MAXN = 55556;

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

  string s;
  cin >> s;
  vector < vector < ll > > v(26, vector < ll > ());
  ll n = s.length();
  for(int i = 0; i < n; i++){
    v[s[i] - 'a'].push_back(i);
  }

  ll ans = (n * (n - 1)) / 2;
  for(int i = 0; i < n; i++){
    ll idx = s[i] - 'a';
    ans -= v[idx].end() - upper_bound(v[idx].begin(), v[idx].end(), i);
  }

  cout << ans + 1 << '\n';
}


#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
#define rep(i, n) for(int i = 0; i < n; i++)
#define REP(i, a, b) for(int i = a; i < b; i++)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define fi first
#define se second
#define debug(x) cerr <<__LINE__<< ": " <<#x<< " = " << x << endl
#define debug_vec(v) cerr<<__LINE__<<": "<<#v<<" = ";rep(i,v.size())cerr<<" "<<v[i];cerr<<endl
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; }
const int INF = (1<<30) - 1;
const ll LINF = (1LL<<60) - 1;

void solve() {
    int n, ans = 0;
    cin >> n;
    vector<pii> A[n];
    rep(i, n) {
        int a;
        cin >> a;
        rep(j, a) {
            int x, y;
            cin >> x >> y;
            x--;
            A[i].push_back({x, y});
        }
    }
    rep(bit, 1 << n) {
        rep(i, n) {
            if ((bit >> i & 1) == 0) continue;
            rep(j, A[i].size()) {
                int x, y;
                tie(x, y) = A[i][j];
                if ((bit >> x & 1) != y) {
                    goto end;
                }
            }
        }
        chmax(ans, __builtin_popcount(bit));
        end:;
    }
    cout << ans << endl;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    solve();
    return 0;
}

#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define erep(i,a,b) for(int i=a;i<=(int)(b);++i)
#define per(i,a,b) for(int i=(a);i>(b);--i)
#define eper(i,a,b) for(int i=(a);i>=b;--i)
#define pb push_back
#define mp make_pair
#define INF 100100100100
#define MOD 1000000007
#define all(x) (x).begin(),(x).end()
#define vii vector<int>
#define vll vector<long long>
using namespace std;
typedef long long ll;
typedef pair<int,int> Pii;
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; }
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 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;}

int n;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
    cin >> n;
    vll a(n);
    rep(i, 0, n) cin >> a[i];
    int k = a[0];
    rep(i, 1, n) k = gcd(k, a[i]);
    vii ans;
    erep(x, 1, k) {
        bool flag = true;
        rep(i, 0, n) {
            if (a[i] % x != 0) flag = false;
        }
        if (flag) {
            ans.pb(x);
        }
    }
    rep(i, 0, ans.size()) cout << ans[i] << endl;
    return 0;
}


#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define printVec(v) printf("{"); for (const auto& i : v) { std::cout << i << ", "; } printf("}\n");
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; }
using namespace std;
using P = pair<int,int>;
using ll = long long;
const ll INF = 1LL<<60;
const double PI = 3.1415926535897932;
const int MOD = 1e9 + 7;

//cin.tie(0);ios::sync_with_stdio(false);
int main() {
  int n;
  string s;
  cin >> n >> s;
  ll ans;
  map<char, ll> m;
  for (int i = 0; i < n; i++) {
    if (s[i] == 'R') m['R']++;
    if (s[i] == 'G') m['G']++;
    if (s[i] == 'B') m['B']++;
  }
  ans = m['R'] * m['G'] * m['B'];
  for (int i = 0; i < n; i++) {
    for (int j = i + 1; j < n; j++) {
      int k = j + j - i;
      if (k < n) {
	if (s[i] != s[j] && s[i] != s[k] && s[j] != s[k]) ans--;
      }
    }
  }

  cout << ans << endl;
  return 0;
}

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

int main() {
    int n;
    cin >> n;
    vector<int> r,g,b;

    for(int i = 0; i < n; i++) {
        char x;
        cin >> x;
        if(x=='R') r.push_back(i+1);
        if(x=='G') g.push_back(i+1);
        if(x=='B') b.push_back(i+1);
    }

    ll ans = r.size()*g.size()*b.size();
    if(ans==0){
        cout << 0 << endl;
        return 0;
    }

    for(int i = 0; i < r.size(); i++) {
        for(int j = 0; j < g.size(); j++) {
            int y=lower_bound(b.begin(),b.end(),g[j]+g[j]-r[i])-b.begin();
            if(y!=b.size()){
                if(b[y]==g[j]+g[j]-r[i]) ans--;
            }
            y=lower_bound(b.begin(),b.end(),r[i]+r[i]-g[j])-b.begin();
            if(y!=b.size()){
                if(b[y]==r[i]+r[i]-g[j]) ans--;
            }

            if((r[i]+g[j])%2==0){
                y=lower_bound(b.begin(),b.end(),(r[i]+g[j])/2)-b.begin();
                if(y!=b.size()){
                if(b[y]==(r[i]+g[j])/2) ans--;
                }
            }
        }
    }

    cout << ans << endl;
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
int levenshtein_distance(string s1, string s2) {
	vector<vector<int> > dp(s1.size() + 1, vector<int>(s2.size() + 1));
	for(int i = 0; i <= s1.size(); i++) {
		for(int j = 0; j <= s2.size(); j++) {
			if(i == 0) dp[i][j] = j;
			else if(j == 0) dp[i][j] = i;
			else {
				dp[i][j] = min({dp[i][j - 1] + 1, dp[i - 1][j] + 1, dp[i - 1][j - 1] + (s1[i - 1] != s2[j - 1])});
			}
		}
	}
	return dp[s1.size()][s2.size()];
}
string s, t;
int main() {
	cin >> s >> t;
	cout << levenshtein_distance(s, t) << endl;
	return 0;
}

#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b;
    cin>>a>>b;
    int ans=0;
    if(a>b)
    {
        ans+=a;
        a-=1;
    }
    else
    {
        ans+=b;
        b-=1;
    }
    ans+=max(a,b);
    cout<<ans;
}


#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <string.h>

//#define __DEBUG__

class Dice {

	private:
		int iNS[4];
		int iEW[4];

	public:
		Dice( int v1, int v2, int v3, int v4, int v5, int v6 ) {
			iNS[0] = v1;
			iNS[1] = v2;
			iNS[2] = v6;
			iNS[3] = v5;

			iEW[0] = v1;
			iEW[1] = v3;
			iEW[2] = v6;
			iEW[3] = v4;

#ifdef __DEBUG__
			printf("NS[%d %d %d %d]\n", iNS[0], iNS[1], iNS[2], iNS[3]);
			printf("EW[%d %d %d %d]\n", iEW[0], iEW[1], iEW[2], iEW[3]);
#endif
		}

		void rotateN() {
			int iTmp = iNS[0];
			iNS[0] = iNS[1];
			iNS[1] = iNS[2];
			iNS[2] = iNS[3];
			iNS[3] = iTmp;

			iEW[0] = iNS[0];
			iEW[2] = iNS[2];

#ifdef __DEBUG__
			printf("NS[%d %d %d %d]\n", iNS[0], iNS[1], iNS[2], iNS[3]);
			printf("EW[%d %d %d %d]\n", iEW[0], iEW[1], iEW[2], iEW[3]);
#endif
		}

		void rotateS() {
			int iTmp = iNS[0];
			iNS[0] = iNS[3];
			iNS[3] = iNS[2];
			iNS[2] = iNS[1];
			iNS[1] = iTmp;

			iEW[0] = iNS[0];
			iEW[2] = iNS[2];

#ifdef __DEBUG__
			printf("NS[%d %d %d %d]\n", iNS[0], iNS[1], iNS[2], iNS[3]);
			printf("EW[%d %d %d %d]\n", iEW[0], iEW[1], iEW[2], iEW[3]);
#endif
		}

		void rotateE() {
			int iTmp = iEW[0];
			iEW[0] = iEW[3];
			iEW[3] = iEW[2];
			iEW[2] = iEW[1];
			iEW[1] = iTmp;

			iNS[0] = iEW[0];
			iNS[2] = iEW[2];

#ifdef __DEBUG__
			printf("NS[%d %d %d %d]\n", iNS[0], iNS[1], iNS[2], iNS[3]);
			printf("EW[%d %d %d %d]\n", iEW[0], iEW[1], iEW[2], iEW[3]);
#endif

		}

		void rotateW() {
			int iTmp = iEW[0];
			iEW[0] = iEW[1];
			iEW[1] = iEW[2];
			iEW[2] = iEW[3];
			iEW[3] = iTmp;

			iNS[0] = iEW[0];
			iNS[2] = iEW[2];

#ifdef __DEBUG__
			printf("NS[%d %d %d %d]\n", iNS[0], iNS[1], iNS[2], iNS[3]);
			printf("EW[%d %d %d %d]\n", iEW[0], iEW[1], iEW[2], iEW[3]);
#endif
		}

		int getTop() {
			return iNS[0];
		}

};

int main(void) {

	int v1, v2, v3, v4, v5, v6;
	char cmd[128];

	v1 = v2 = v3 = v4 = v5 = v6 = 0;

	scanf("%d %d %d %d %d %d", &v1, &v2, &v3, &v4, &v5, &v6 );
	scanf("%s", &cmd );

	Dice *d = new Dice(v1, v2, v3, v4, v5, v6);

	int iLen = strlen(cmd);
	for (int i = 0; i < iLen; i++) {
		char c = cmd[i] & 0xdf;
		switch (c) {
			case 'N':
				d->rotateN();
				break;
			case 'S':
				d->rotateS();
				break;
			case 'E':
				d->rotateE();
				break;
			case 'W':
				d->rotateW();
				break;
			default:
				break;
		}
	}

	printf("%d\n", d->getTop());

}

//	-*- mode: C++ -*-
//	Dice I
//
//		Write a program to simulate rolling a dice, which can be constructed by the following net.
//
//
//
//
//
//
//		As shown in the figures, each face is identified by a different label from 1 to 6.
//
//		Write a program which reads integers assigned to each face identified by the label and a sequence of commands to roll the dice, and prints the integer on the top face. At the initial state, the dice is located as shown in the above figures.
//
//	Input
//		In the first line, six integers assigned to faces are given in ascending order of their corresponding labels.
//
//		In the second line, a string which represents a sequence of commands, is given. The command is one of 'E', 'N', 'S' and 'W' representing four directions shown in the above figures.
//
//	Output
//		Print the integer which appears on the top face after the simulation.
//
//	Constraints
//		0≤ the integer assigned to a face ≤100
//		0≤ the length of the command ≤100
//	Sample Input 1
//		1 2 4 8 16 32
//		SE
//	Sample Output 1
//		8
//		You are given a dice where 1, 2, 4, 8, 16 are 32 are assigned to a face labeled by 1, 2, ..., 6 respectively. After you roll the dice to the direction S and then to the direction E, you can see 8 on the top face.
//
//
//
//	Sample Input 2
//		1 2 4 8 16 32
//		EESWN
//	Sample Output 2
//		32

#include <iostream>
#include <vector>
#include <string>

const unsigned int	faces	{6};

void	E(std::vector<unsigned int>& dice);
void	N(std::vector<unsigned int>& dice);
void	S(std::vector<unsigned int>& dice);
void	W(std::vector<unsigned int>& dice);

int	main(int	argc,
		 char*	argv[])
{
	std::vector<unsigned int>	dice	{};
	dice.resize(faces, 0);

	for(unsigned int i = 0; i < faces; i++){
		std::cin >> dice[i];
	}

	std::string	commands	{};
	std::cin >> commands;

	for(unsigned int i = 0; i < commands.length(); i++){
		switch(commands[i]){
		case 'E':
			E(dice);
			break;
		case 'N':
			N(dice);
			break;
		case 'S':
			S(dice);
			break;
		case 'W':
			W(dice);
			break;
		default:
			break;
		}
	}

	std::cout << dice[0] << '\n';
    return 0;
}

void	E(std::vector<unsigned int>& dice)
{
	unsigned int	x	= dice[0];
	dice[0]	= dice[3];
	dice[3]	= dice[5];
	dice[5]	= dice[2];
	dice[2]	= x;
}

void	N(std::vector<unsigned int>& dice)
{
	unsigned int	x	= dice[0];
	dice[0]	= dice[1];
	dice[1]	= dice[5];
	dice[5]	= dice[4];
	dice[4]	= x;
}

void	S(std::vector<unsigned int>& dice)
{
	unsigned int	x	= dice[0];
	dice[0]	= dice[4];
	dice[4]	= dice[5];
	dice[5]	= dice[1];
	dice[1]	= x;
}

void	W(std::vector<unsigned int>& dice)
{
	unsigned int	x	= dice[0];
	dice[0]	= dice[2];
	dice[2]	= dice[5];
	dice[5]	= dice[3];
	dice[3]	= x;
}


#include <algorithm>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;

typedef long long ll;

#define MOD 1000000007

int main() {
  string s;
  cin >> s;
  bool ok = false;
  if (s == "hi") ok = true;
  if (s == "hihi") ok = true;
  if (s == "hihihi") ok = true;
  if (s == "hihihihi") ok = true;
  if (s == "hihihihihi") ok = true;
  cout << (ok ? "Yes" : "No") << endl;
  return 0;
}

#include<bits/stdc++.h>
#include<boost/variant.hpp>
using namespace std;
typedef long long ll;
typedef vector<boost::variant<bool, ll, int, string, double, char*, const char*>> anys;
template<typename T> inline void pr(const vector<T> &xs){
	for(int i=0; i<xs.size()-1; i++) cout<<xs[i]<<" ";
	(xs.empty()?cout:(cout<<xs[xs.size()-1]))<<endl;
}
#ifdef DEBUG
#define debug(...) pr(anys{__VA_ARGS__})
#define debugv(x) pr((x))
#else
#define debug(...)
#define debugv(x)
#endif

int main(){
	string S;
	cin >> S;
	string ans = S.size()%2==0 ? "Yes" : "No";
	for(int i=0; i<S.size(); i++){
		if(S[i]!=(i%2==0?'h':'i')) ans = "No";
	}
	cout << ans << endl;

	return 0;
}


#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <time.h>
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <fstream>
#include <vector>
#include <bitset>
#include <queue>
#include <stack>
#include <map>
#include <set>

using namespace std;

int n,m;
int a[105];

int main()
{
	scanf("%d%d",&n,&m);
	int odd1 = 0,odd2 = 0;
	for (int i = 1;i <= m;i++)
	{
		scanf("%d",&a[i]);
		if (a[i] & 1)
		{
			if (!odd1)
				odd1 = i;
			else if (!odd2)
				odd2 = i;
			else
			{
				puts("Impossible");
				return 0;
			}
		}
	}
	if (odd1)
		swap(a[odd1],a[1]);
	if (odd2)
		swap(a[odd2],a[m]);
	for (int i = 1;i <= m;i++)
		printf("%d ",a[i]);
	printf("\n");
	if (m == 1)
	{
		if (a[1] == 1)
		{
			puts("1");
			printf("1\n");
		}
		else
		{
			puts("2");
			printf("%d %d\n",a[1] - 1,1);
		}
		return 0;
	}
	printf("%d\n%d ",m - (a[m] == 1),a[1] + 1);
	for (int i = 2;i < m;i++)
		printf("%d ",a[i]);
	if (a[m] > 1)
		printf("%d",a[m] - 1);
	printf("\n");
	return 0;
}

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define loop(__x, __start, __end) for(int __x = __start; __x < __end; __x++)

typedef pair<int, int> P;
int N;
vector<int> A;
const int MONOID = 0;
ll f(ll x, ll y) {
  return x + y;
}

void add(ll x, ll y) {
  ll i = x + N - 1;
  A.at(i) += y;
  while (i > 0) {
    i = (i-1)/2;
    A.at(i) = f(A.at(i*2+1), A.at(i*2+2));
  }
}

ll findRec(ll x, ll y, ll n, ll l, ll r) {
  if (r <= x || y <= l) return MONOID;
  if (x <= l && r <= y) return A.at(n);
  return f(
    findRec(x, y, n*2+1, l, (l+r)/2),
    findRec(x, y, n*2+2, (l+r)/2, r)
  );
}

ll find(ll x, ll y) {
  return findRec(x, y+1, 0, 0, N);
}

int main() {
  int n,q; cin >> n >> q;
  N = 1;
  while (N < n) N *= 2;
  vector<int> C(n);
  A.assign(3*n, 0);
  loop(i,0,n) cin >> C[i];

  vector<int> points[n+1];
  vector<int> prev(n+1, -1);
  loop(i,0,n) {
    int c = C[i];
    if (prev[c] != -1) {
      points[prev[c]].emplace_back(i);
    }
    prev[c] = i;
  }

  vector<P> qs[n+1];
  loop(i,0,q) {
    int l,r;cin >> l >> r;
    l--;r--;
    qs[l].emplace_back(r, i);
  }

  vector<int> ans(q, 0);
  for (int x=n-1; x>=0; x--) {
    for (auto &&y: points[x]) {
      add(y, 1);
    }
    for (auto q: qs[x]) {
      ans[q.second] = q.first-x+1-find(0, q.first);
    }
  }
  loop(i,0,q) cout << ans[i] << endl;
  return 0;
}


#include<iostream>
#include<vector>
#include<queue>
#include<climits>
using namespace std;

typedef long long ll;

const ll INF = 2000000000000;
const int dmax = 2000000001;

int main(){

	ll V,E,s,t,cost;
	cin >> V >> E;

	ll A[V][V];

	for (int i=0;i<V;i++){
		for (int j=0;j<V;j++){
			A[i][j]=INF;
		}
	}

	for (int i=0;i<E;i++){
		cin >>  s >> t >> cost;
		A[s][t]=cost;
	}

	ll d[V][V][V];

	for (int i=0;i<V;i++){
		for (int j=0;j<V;j++){
			if(i!=j){
				d[i][j][0]=min(A[i][j],A[i][0]+A[0][j]);
			}else{
				d[i][j][0]=0;
			}
		}
	}

	for (int k=1;k<V;k++){
		for (int i=0;i<V;i++){
			for (int j=0;j<V;j++){
				d[i][j][k]=min(d[i][j][k-1],d[i][k][k-1]+d[k][j][k-1]);
			}
		}
	}

	for (int i=0;i<V;i++){
		for (int j=0;j<V;j++){
			if(d[i][j][V-1]<0 && d[j][i][V-1]<0){
				cout <<"NEGATIVE CYCLE" <<endl;
				return 0;
			}
		}
	}

	for (int i=0;i<V;i++){
		for (int j=0;j<V;j++){
			if(d[i][j][V-1]>dmax){
				cout << "INF";
			}else{
				cout << d[i][j][V-1];
			}
			if(j!=V-1){
				cout << " ";
			}
		}
		cout << endl;
	}

	return 0;
}


// #define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define uint unsigned int
#define ull  unsigned long long
typedef string str;
typedef long long ll;
typedef double db;
typedef pair<int, int> pii;
typedef map<int, int> mii;
typedef vector<int> vi;
typedef vector<bool> vb;
#define pb push_back
#define fi first
#define se second
#define in insert
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define speed ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
const int INF = 1e9 + 5;
const int N = 2e5 + 123;
int main(){
    speed;
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    for(int i = 1; i <= (d - b); ++i){
        cout << 'U';
    }
    for(int i = 1; i <= (c - a); ++i){
        cout << 'R';
    }
    for(int i = 1; i <= (d - b); ++i){
        cout << 'D';
    }
    for(int i = 1; i <= (c - a); ++i){
        cout << 'L';
    }
    cout << 'L';
    for(int i = 1; i <= (d - b) + 1; ++i){
        cout << 'U';
    }
    for(int i = 1; i <= (c - a) +1;++i){
        cout << 'R';
    }
    cout << 'D';
    cout << 'R';
    for(int i = 1; i <= (d - b) + 1; ++i){
        cout << 'D';
    }
    for(int i = 1; i <= (c - a) + 1; ++i){
        cout << 'L';
    }
    cout << 'U';
}

/**
 * auther: moririn_cocoa
 */
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <bitset>
#include <stdio.h>
#include <stdlib.h>
using namespace std;

#define rep(i,n) for(int i=0;i<(n);i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define fi first
#define se second
#define ll long long
#define pll pair<ll,ll>
#define pq priority_queue
#define ios ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define lb(c,x) distance(c.begin(),lower_bound(all(c),x))
#define ub(c,x) distance(c.begin(),upper_bound(all(c),x))

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 argc, const char * argv[]) {

  int A;
  int B;
  int C;
  int D;

  cin >> A;
  cin >> B;
  cin >> C;
  cin >> D;

  cout << min ( A,B ) + min ( C,D ) << endl;

  return 0;
}


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

int main() {
  string A, B, S;
  cin >> A >> B >> S;
  cout << ((regex_match(S, regex("\\d{" + A + "}-\\d{" + B + "}"))) ? "Yes" : "No") << "\n";
}

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

int main(){
    int a,b,total=0;
	scanf("%d %d",&a,&b);

    char s[a+b+2];
    scanf("%s", &s);

    for(int i=0; i<a+b+1 ;i++){
        if(i!=a){
            if(s[i]>=48 && s[i]<=57){
                total++;
            }
        }
		else {
            if(s[i] == '-'){
                total++;
            }
        }
    }

    if (total==a+b+1){
    	printf("Yes");
	}
	else {
		printf("No");
	}

    return 0;
}


//#define __USE_MINGW_ANSI_STDIO 0
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef pair<int, int> PII;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define IN(a, b, x) (a<=x&&x<b)
#define MP make_pair
#define PB push_back
#define MOD 1000000007
#define INF (1LL<<30)
#define LLINF (1LL<<60)
#define PI 3.14159265359
#define EPS 1e-12
//#define int ll

signed main(void)
{
	int d;
	while(cin >> d) {
		ll sum = 0;
		for(int i=d; i<=600-d; i+=d) {
			sum += d*i*i;
		}
		cout << sum << endl;
	}

	return 0;
}

#include<iostream>
#include<cstdio>
#include<stack>
using namespace std;

int main(){
    string str ;
    while ( cin >> str ){
        int len = str.size() ;
        stack<char> container ;
        for ( int i = 0 ; i < str.size() ; i ++ ){
            if ( str[i] == 'T' ){
                if ( !container.empty() ){
                    if ( container.top() == 'S' ){
                        len -= 2 ;
                        container.pop() ;
                    }
                }else{
                    container.push(str[i]) ;
                }
            }else{
                container.push(str[i]) ;
            }
        }
        cout << len << endl ;
    }
    return 0 ;
}


#include<bits/stdc++.h>
#define fast ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define pb push_back
#define ll long long
#define ull unsigned long long
#define ii pair<int,int>
#define iii pair <int,ii>
#define iil pair<ll,ll>
#define iiil pair<ll,iil>
#define max3(a,b,c) max(a, max(b,c))
#define min3(a,b,c) min(a, min(b,c))
#define s(v) sort(v.begin(),v.end())
#define pf printf
#define sf scanf
#define MIN INT_MIN
#define MAX INT_MAX
#define Accepted 0
#define GCD(x,y)  __gcd(x, y)
#define endl "\n"
using namespace std;
/**
const int maxn = 1e5 * 3;
int vis[maxn],l[maxn];
int indegree[maxn];
vector<int> graph[maxn];
vector<int> order;
vector<int> cst[maxn];

int gx[]= {2,2,-2,-2,1,-1,1,-1};
int gy[] ={1,-1,1,-1,2,2,-2,-2};

void DFS(int a,bool tpsort){
        vis[a] = 1;
    for(int i=0;i<graph[a].size();i++){
        int r = graph[a][i];
            if(vis[r]==0){
                DFS(r,tpsort);
            }
    }
    if(tpsort)order.push_back(a);
}

int vis[maxn],l2[maxn];

void BFS(int root){
    memset(vis,0,sizeof(vis));
    memset(l,0,sizeof(l));
    vis[root] = 1;
    l[root] = 0;
    queue <int> q;
    ans = 0;
    mx = root;
    q.push(root);
    while(!q.empty()){
        int cur = q.front();
        q.pop();
        int p = graph[cur].size();
        for(int i=0;i<p;i++){
            int r = graph[cur][i];
            if(vis[r]==0){
                vis[r] = 1 ;
                l[r] = l[cur] + cst[cur][i];
                if(l[r]>ans){
                    ans = l[r];
                    mx = r;
                }
                q.push(r);
            }
        }
    }
   // cout<< ans <<endl;
}

**/

int main(){
    //fast
    int n,val;  cin >> n;
    vector<int> v;

    for(int i=0;i<2*n;i++){
        cin>>val;
        v.pb(val);
    }

    s(v);
    int sum = 0;
    for(int i=0;i<2*n;i+=2){
        sum+=v[i];
    }
        cout << sum << endl;

    return Accepted;
}

#include<iostream>
using namespace std;
int main(){
  int n,a=0,b=0,aa,bb;
  cin>>n;
  while(n!=0){
    for(int i=0;i<n;i++){
    cin>>aa>>bb;
    if(aa<bb){
      b+=aa+bb;
    }else if(aa>bb){
      a+=aa+bb;
    }else if(aa==bb){
      a+=aa;
      b+=bb;
    }
  }
    cout<<a<<" "<<b<<endl;
    cin>>n;
    a=0;
    b=0;
  }
  return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define int long long
#define PI 3.141592653589793
#define rep(i, n) for (int i = 0; i < (n); i++)
#define REP(i, a, n) for (int i = a; i < (n); i++)
#define rrep(i, n, k) for (int i = (n); i >= (k); i--);
#define all(x) (x).begin(), (x).end()
#define vi vector<int>
template<class T> istream &operator>>(istream&is,vector<T>&v){for(auto &elemnt:v)is>>elemnt;return is;}
template<class T,class U> istream &operator>>(istream&is,pair<T,U>&p){is>>p.first>>p.second;return is;}
template<class T>vector<T> make_vector(size_t a){return vector<T>(a);}
template<class T, class... Ts>auto make_vector(size_t a, Ts... ts){return vector<decltype(make_vector<T>(ts...))>(a, make_vector<T>(ts...));}
const int MOD = 2;
const int INF = 2e18;

signed main() {
    int N, M;
    cin >> N >> M;
    vector<vector<int>> G(N + 1);
    vector<int> count(N + 1, 0);
    int start = 0;
    {
        set<int> remain;
        for (int i = 1; i <= N; i++) remain.insert(i);
        for (int i = 0; i < N + M - 1; i++) {
            int A, B;
            cin >> A >> B;
            G[A].push_back(B);
            count[B]++;
            remain.erase(B);
        }
        start = *remain.begin();
    }
    vector<int> ans(N + 1, -1), dis(N + 1, -1);
    ans[start] = 0;
    dis[start] = 0;
    queue<int> explore;
    explore.push(start);
    while (!explore.empty()) {
        int now = explore.front();
        explore.pop();
        for (int next : G[now]) {
            count[next]--;
            if (dis[next] < dis[now] + 1) {
                dis[next] = dis[now] + 1;
                ans[next] = now;
            }
            if (count[next] == 0) explore.push(next);
        }
    }
    for (int i = 1; i <= N; i++) cout << ans[i] << endl;
}

#include <bits/stdc++.h>
#include <atcoder/all>
#define REP(i, n) for (ll i = 0; i < n; i++)
#define IREP(i, n) for (ll i = n - 1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define all(v) v.begin(), v.end()
typedef long long ll;
using namespace atcoder;

int main(){
    int n,q;
    std::cin >> n >> q;
    fenwick_tree<ll> fw(n);
    REP(i,n){
        int input;
        std::cin >> input;
        fw.add(i,input);
    }
    REP(i,q){
        int f,p,x;
        std::cin >> f >> p >> x;
        if(f==0){
            fw.add(p,x);
        }
        else{
            std::cout << fw.sum(p,x) << std::endl;
        }
    }
}


#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<bitset>
#include<deque>
#include<functional>
#include<iterator>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<utility>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
#define a first
#define b second
#define sz(x) (ll)((x).size())
#define pb push_back
#define mp make_pair
#define bg begin()
#define ed end()
#define all(x) (x).bg,(x).ed
#define rep(i,n) for(ll i=0;i<(n);i++)
#define rep1(i,n) for(ll i=1;i<=(n);i++)
#define rrep(i,n) for(ll i=(n)-1;i>=0;i--)
#define rrep1(i,n) for(ll i=(n);i>=1;i--)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
const ll MOD=1000000007;
const ll INF=1000000000000000;
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;}
ll maxx(ll x,ll y,ll z){return max(max(x,y),z);}
ll minn(ll x,ll y,ll z){return min(min(x,y),z);}
ll gcd(ll x,ll y){if(x%y==0) return y;else return gcd(y,x%y);}
ll lcm(ll x,ll y){return x*(y/gcd(x,y));}
ll digsz(ll x){if(x==0) return 1;else{ll ans=0;while(x){x/=10;ans++;}return ans;}}
ll digsum(ll x){ll sum=0;while(x){sum+=x%10;x/=10;}return sum;}
vector<ll> pw2(62,1);vector<ll> pw_2(62,1);

int main(){
    {rep1(i,61) pw2[i]=2*pw2[i-1];}
    {rep1(i,61) pw_2[i]=-2*pw_2[i-1];}

    ll N; cin>>N;

    if(N==0){
        cout<<0<<endl;
        return 0;
    }
    vector<ll> ans;
    ll rem=N;
    ll i=0;
    while(rem!=0){
        if(rem%pw2[i+1]!=0){
            ans.pb(1);
            rem-=pw_2[i];
        }
        else ans.pb(0);

        i++;
    }
    rrep(i,sz(ans)) cout<<ans[i];
}

#pragma GCC optimize ("O2")
#pragma GCC target ("avx2")
//#include<bits/stdc++.h>
#include<iostream>
#include<algorithm>
#include<cstring>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

const int cm = 1 << 17;
char cn[cm], * ci = cn + cm, ct;
inline char getcha() {
	if (ci - cn == cm) { fread_unlocked(cn, 1, cm, stdin); ci = cn; }
	return *ci++;
}
inline int getint() {
	int A = 0;
	if (ci - cn + 16 > cm) while ((ct = getcha()) >= '0') A = A * 10 + ct - '0';
	else while ((ct = *ci++) >= '0') A = A * 10 + ct - '0';
	return A;
}
const int dm = 1400000;
char dn[dm], * di = dn;
const int MAX = 20000;
class unko {
public:
	char C[MAX * 7 + 10], *K[MAX + 10];
	constexpr unko() : C(), K() {
		auto di = C + 3;
		C[0] = '0';
		C[0] = ' ';
		C[0] = '\n';
		K[0] = C;
		K[1] = di;
		rep1(i, MAX) {
			int X = i;
			int keta = 0;
			char c[10] = {};
			while (X) {
				*(c + keta) = '0' + X % 10;
				X /= 10;
				keta++;
			}
			for (int j = keta - 1; j >= 0; j--)* di++ = (*(c + j));
			*di++ = ' ';
			*di++ = '\n';
			K[i + 1] = di;
		}
	}
};
constexpr unko f;
inline void putint(int X) {
	if (X > 20000) {
		int ue = X / 10;
		for (auto i = f.K[ue]; *i != ' '; i++) *di++ = *i;
		*di++ = '0' + X % 10;
		*di++ = ' ';
	}
	else for (auto i = f.K[X]; *i != '\n'; i++)* di++ = *i;
}

int main() {
	//cin.tie(0);
	//ios::sync_with_stdio(false);

	int N = getint(), K = getint();

	int A[200001];
	rep(i, N) A[i] = getint();
	ll owa = ll(N) * N;

	rep(p, K) {
		int B[200001] = {};
		rep(i, N) {
			B[max(0, i - A[i])]++;
			B[min(N, i + A[i] + 1)]--;
		}
		ll kei = B[0];
		A[0] = B[0];
		rep1(i, N - 1) {
			kei += (A[i] = A[i - 1] + B[i]);
		}
		if (kei == owa) break;
	}

	rep(i, N) putint(A[i]);
	fwrite(dn, 1, di - dn, stdout);

	Would you please return 0;
}


#include <bits/stdc++.h>

// #undef DEBUG  // Uncomment this line to forcefully disable debug print.
#if DEBUG
template <typename T>
void debug(T value) {
  std::cerr << value;
}
template <typename T, typename... Ts>
void debug(T value, Ts... args) {
  std::cerr << value << ", ";
  debug(args...);
}
#define dbg(...)                              \
  do {                                        \
    cerr << #__VA_ARGS__ << ": ";             \
    debug(__VA_ARGS__);                       \
    cerr << " (L" << __LINE__ << ")" << endl; \
  } while (0)
#else
#define dbg(...)
#endif

void read_from_cin() {}
template <typename T, typename... Ts>
void read_from_cin(T& value, Ts&... args) {
  std::cin >> value;
  read_from_cin(args...);
}
#define in(type, ...) \
  type __VA_ARGS__;   \
  read_from_cin(__VA_ARGS__);

template <typename T>
void write_to_cout(const T& value) {
  std::cout << value << std::endl;
}
template <typename T, typename... Ts>
void write_to_cout(const T& value, const Ts&... args) {
  std::cout << value << ' ';
  write_to_cout(args...);
}
#define out(...) write_to_cout(__VA_ARGS__);

#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)

using ll = long long;

using namespace std;

struct Construction {
  ll s, t, x;
  bool operator<(const Construction& c) const { return s < c.s; }
};

struct Person {
  ll d, index;
  bool operator<(const Person& p) const { return d < p.d; }
};

int main() {
  in(ll, n, q);
  vector<Construction> c(n);
  rep(i, n) {
    cin >> c[i].s >> c[i].t >> c[i].x;
    c[i].s -= c[i].x;
    c[i].t -= c[i].x;
  }
  sort(all(c));
  vector<Person> p(q);
  rep(i, q) {
    cin >> p[i].d;
    p[i].index = i;
  }
  sort(all(p));

  multiset<ll> active;
  priority_queue<pair<ll, ll>> que;
  auto cit = c.begin();
  vector<ll> ans(q);
  for (const auto& pi : p) {
    dbg(pi.d, pi.index);
    while (cit != c.end() && cit->s <= pi.d) {
      dbg(cit->s, cit->t, cit->x);
      que.push({-cit->t, cit->x});
      active.insert(cit->x);
      ++cit;
    }
    while (!que.empty() && -que.top().first <= pi.d) {
      dbg(-que.top().first, que.top().second);
      active.erase(active.find(que.top().second));
      que.pop();
    }
    if (active.empty()) {
      ans[pi.index] = -1;
    } else {
      ans[pi.index] = *active.begin();
    }
  }
  rep(i, q) out(ans[i]);
}

#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>
#include <queue>
#include <stack>
#include <unordered_set>

using namespace std;

typedef long long int ll;
typedef pair<int, int> Pii;

const ll mod = 1000000007;

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

  int n, q;
  cin >> n >> q;
  vector<vector<int> > stx(n, vector<int>(3));
  for (auto &x: stx) cin >> x[0] >> x[1] >> x[2];
  vector<int> d(q);
  for (auto &x: d) cin >> x;

  for (auto &x: stx) {
    x[0] -= x[2];
    x[1] -= x[2];
  }

  vector<int> time, pos;
  priority_queue<Pii, vector<Pii>, greater<Pii> > pque;
  priority_queue<int, vector<int>, greater<int> > watching;
  unordered_set<int> roadblock;
  for (auto &x: stx) {
    pque.emplace(x[0], x[2]);
    pque.emplace(x[1], x[2]);
  }
  int lastTime = -1000000007;
  while (!pque.empty()) {
    auto now = pque.top();
    pque.pop();
    if (now.first > lastTime) {
      while (!watching.empty()) {
        auto next = watching.top();
        if (roadblock.find(next) == roadblock.end()) watching.pop();
        else break;
      }
      if (watching.empty()) {
        time.push_back(lastTime);
        pos.push_back(-1);
      }
      else {
        auto next = watching.top();
        time.push_back(lastTime);
        pos.push_back(next);
      }
      lastTime = now.first;
    }
    if (roadblock.find(now.second) == roadblock.end()) {
      roadblock.insert(now.second);
      watching.push(now.second);
    }
    else {
      roadblock.erase(now.second);
    }
  }
  time.push_back(lastTime);
  pos.push_back(-1);

  vector<int> ans(q);
  for (int i = 0; i < q; i++) {
    auto it = upper_bound(time.begin(), time.end(), d[i]);
    int idx = distance(time.begin(), it) - 1;
    ans[i] = pos[idx];
  }

  for (auto &x: ans) cout << x << endl;

  return 0;
}


//#pragma  GCC optimize("Ofast")

//#ifdef  DEBUG
//#define _GLIBCXX_DEBUG
//#endif

// -Ofast
// -O3
// -O2
// -fsanitize=address
// -fsanitize=undefined

// add_compile_options()

#include <iostream>
#include <map>
#include <vector>
#include <set>
#include <stack>
#include <bitset>
#include <queue>
#include <algorithm>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
#include <iomanip>
#include <unordered_map>
#include <cmath>
#include <cassert>
#include <random>

using namespace std;
//using namesparsace __gnu_pbds;

void solve();

int main() {
    srand(time(0));
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
#ifdef DEBUG
    freopen("input.txt", "r", stdin);
#endif
    solve();
    return 0;
}

#define ld double
#define int long long

const int maxN = 3e3 + 10, maxK = 1e5 + 10, inf = 1e15 + 10, mod = 1e9 + 7, base = 223;

int n, a[16][16], cost[1 << 16], dp[1 << 16];

bool bit(int a, int i) {
    return (a >> i) & 1;
}

int get(int mask) {
    vector < int > v;
    int res = 0;
    for (int i = 0; i < n; i++) {
        if (bit(mask, i)) {
            for (int j = 0; j < v.size(); j++) {
                res += a[v[j]][i];
            }
            v.push_back(i);
        }
    }
    return res;
}

void solve() {
    cin >> n;
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            cin >> a[i][j];
        }
    }
    for (int i = 1; i < (1 << n); i++) {
        cost[i] = get(i);
    }
    for (int mask = 1; mask < (1 << n); mask++) {
        int submask = mask;
        while (submask > 0) {
            dp[mask] = max(dp[mask], dp[mask ^ submask] + cost[submask]);
            submask = mask & (submask - 1);
        }
    }
    cout << dp[(1 << n) - 1];
}

// submask = mask & (mask - 1);

#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <set>
#include <cmath>
#include <map>
#include <stack>
#include <queue>
#include <iomanip>
#define MOD(x) (x + 1000000007) % (1000000007)

using namespace std;

template <class t>
using vec = vector<t>;
using ll = long long;

const int MAX = numeric_limits<int>::max();

template <class t>
ostream &operator<<(ostream &out, vec<t> &v)
{
    for (auto &e : v)
        out << e << " ";
    out << "\n";
    return out;
}

template <class t>
istream &operator>>(istream &in, vec<t> &v)
{
    for (auto &e : v)
        in >> e;
    return in;
}

int n;
vec<vec<ll>> a;
vec<ll> dp, pre;

void find(ll used, vec<int> &not_used, ll group_mask, int index)
{
    if (index == not_used.size())
    {
        dp[used | group_mask] = max(dp[used | group_mask], dp[used] + pre[group_mask]);
        return;
    }
    find(used, not_used, group_mask, index + 1);
    find(used, not_used, group_mask | (1 << not_used[index]), index + 1);
}

int main()
{
    cin >> n;
    a = vec<vec<ll>>(n, vec<ll>(n));
    cin >> a;
    dp = vec<ll>(1 << n);
    pre = vec<ll>(1 << n);
    for (ll mask = 0; mask < (1 << n); mask++)
        for (int i = 0; i < n; i++)
            if (mask & (1 << i))
                for (int j = i + 1; j < n; j++)
                    if (mask & (1 << j))
                        pre[mask] += a[i][j];
    for (ll mask = 0; mask < (1 << n); mask++)
    {
        vec<int> not_used;
        for (int i = 0; i < n; i++)
            if (!(mask & (1 << i))) not_used.push_back(i);
        find(mask, not_used, 0, 0);
    }
    cout << dp[(1 << n) - 1];
    return 0;
}


#include <iostream>

using namespace std;

int main()
{
    int a,b,c,d,e;
    cin>>a>>b>>c>>d;
    if(a>b)
    {
        e=a;
        a=b;
        b=e;
    }
    if(c>d)
    {
        e=c;
        c=d;
        d=e;
    }
       cout<<(a+c);

    return 0;
}

#include <bits/stdc++.h>
#define REP(i,n) for (int i=0; i<(n); ++i)
#define REPR(i,n,m) for (int i=(n); i>=(m); --i)
using namespace std;
using LL = long long;
using LD = long double;
using PLL = pair<long long, long long>;
using PLD = pair<long double, long double>;
using VLL = vector<long long>;
using VLD = vector<long double>;
using VPLL = vector<PLL>;
using VPLD = vector<PLD>;

const int INF = numeric_limits<int>::max();

// (x, y) の最大公約数を返す関数
LL GCD(LL x, LL y) {
    return y ? GCD(y, x%y) : x;
}

VPLL prime_factorize(LL n) {
    VPLL res;
    for (LL p=2; p*p<=n; p++) {
        if (n%p!=0) continue;
        int num = 0;
        while (n%p==0) {num++; n/=p;}
        res.push_back(make_pair(p,num));
    }
    if (n!=1) res.push_back(make_pair(n,1));
    return res;
}

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

    LL a, b;
    cin >> a >> b;
    long long G = GCD(a,b);
    auto pf = prime_factorize(G);

    cout << pf.size()+1 << endl;

    return 0;
}


#include <cstdio>
#include <cstring>

#define ZeroMemory(ptr, size)	::memset(ptr, 0, size)

typedef struct
{
	int id;
	int cost;
	int acquired;
} COMPETITION;

typedef struct
{
	int cost;
} COMMITEE;

#define MAX_N	1000

int MaxAcquiredID(COMPETITION *lpCompes, int num)
{
	int id = 0;
	int max = 0;

	for (int i = 0; i < num; i++)
	{
		if (max < lpCompes[i].acquired)
		{
			max = lpCompes[i].acquired;
			id = lpCompes[i].id;
		}
	}

	return(id);
}

int main()
{
	COMPETITION	compes[MAX_N];
	COMMITEE	commits[MAX_N];
	int compesNum, commitsNum;

	// Init
	ZeroMemory(compes, sizeof(compes));
	ZeroMemory(commits, sizeof(commits));

	// Inputs
	::scanf("%i %i", &compesNum, &commitsNum);

	for (int i = 0; i < compesNum; i++)
	{
		compes[i].id = i + 1;
		::scanf("%i", &compes[i].cost);
	}
	for (int i = 0; i < commitsNum; i++)
	{
		::scanf("%i", &commits[i].cost);
	}

	// Vote
	for (int i = 0; i < commitsNum; i++)
	{
		for (int j = 0; j < compesNum; j++)
		{
			//::printf(">>%i, %i\n", compes[j].cost, commits[i].cost);
			if (compes[j].cost <= commits[i].cost)
			{
				compes[j].acquired++;
				break;
			}
		}
	}
	/*
	for (int i = 0; i < compesNum; i++)
	{
		::printf(">%i\n", commits[i].cost);
	}
	*/
	::printf("%i\n", ::MaxAcquiredID(compes, compesNum));
}


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

// int main(){
// 	ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
// 	int tc;
// 	cin >> tc;
// 	while(tc--){
// 		string s;
// 		cin >> s;
// 		int count_0 = 0, count_1 = 0;
// 		for(char ch : s)
// 			count_0 += 1 - ch + '0', count_1 += ch - '0';
// 		int ans = min(count_0, count_1);
// 		int c0 = 0, c1 = 0, n = s.size();
// 		for(int i = 0; i < n - 1; i++){
// 			c0 += 1 - s[i] + '0', c1 += s[i] - '0';
// 			ans = min(ans, c0 + count_1 - c1);
// 			ans = min(ans, c1 + count_0 - c0);
// 		}
// 		cout << ans << '\n';
// 	}
// }
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
#define ll long long
//increase stack size
#pragma comment(linker, "/STACK:16777216")

ll mxm() {return LLONG_MIN;}
template<typename... Args>
ll mxm(ll a, Args... args) { return max(a,mxm(args...)); }

ll mnm() {return LLONG_MAX;}
template<typename... Args>
ll mnm(ll a, Args... args) { return min(a,mnm(args...)); }

template<class T> ostream& operator<<(ostream& os,vector<T> V){
	os<<"[ ";for(auto v:V)os<<v<<" ";return os<<"]";
}
template<class L,class R> ostream& operator<<(ostream& os,pair<L,R> P){
	return os<<"("<<P.first<<","<<P.second<<")";
}

#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__,__VA_ARGS__)
template<typename Arg1>
void __f(const char* name,Arg1&& arg1){
	cout<<name<<" : "<<arg1<<endl;
}
template <typename Arg1,typename... Args>
void __f(const char* names,Arg1&& arg1,Args&&... args){
	const char* comma=strchr(names+1,',');cout.write(names,comma-names)<<" : "<<arg1<<" | ";__f(comma+1,args...);
}
#else
#define trace(...) 1
#endif

#define ld long double
#define pll pair<ll,ll>
#define ii pair<int,int>
#define vll vector<ll>
#define vii vector<ii>
#define vi vector<int>
#define vpll vector<pll>
#define vld vector<ld>
#define vvld vector<vld>
#define vvi vector<vi>
#define vvll vector<vll>
#define vvpll vector<vpll>
#define vvii vector<vii>
#define I insert
#define F first
#define S second
#define pb push_back
#define endl "\n"
#define all(x)	x.begin(),x.end()

const int mod=1e9+7;
// 128 bit: __int128
inline int add(int a,int b){a+=b;if(a>=mod)a-=mod;return a;}
inline int sub(int a,int b){a-=b;if(a<0)a+=mod;return a;}
inline int mul(int a,int b){return (a*1ll*b)%mod;}
inline int power(int a,int b){int rt=1;while(b>0){if(b&1)rt=mul(rt,a);a=mul(a,a);b>>=1;}return rt;}
inline int inv(int a){return power(a,mod-2);}

struct compare{
	bool operator() (const int &a,const int &b) const{
		return a>b;
	}
};

int main()
{
	ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);cout<<setprecision(25);
	int n;
	cin >> n;
	vector<string> v(n);
	for(int i = 0; i < n; i++)
		cin >> v[i];
	vector<pair<int, int> > balances, negative_balances;
	for(int i = 0; i < n; i++){
		int tot = 0, mn = 0;
		for(auto j : v[i]){
			if(j == '(')
				tot++;
			else tot--;
			mn = min(mn, tot);
		}
		if(tot < 0)
			negative_balances.push_back({tot - mn, -tot});
		else
			balances.push_back({-mn, tot});
	}
	sort(all(balances));
	sort(all(negative_balances));
	reverse(all(negative_balances));
	int mn_neg_sum = 0, cur_neg_sum = 0;
	for(auto i : negative_balances){
		mn_neg_sum = max(mn_neg_sum, cur_neg_sum + i.first + i.second);
		cur_neg_sum += i.second;
	}
	int mn_seen = 0;
	for(auto i : balances)
		if(i.first > mn_seen){
			cout << "No" << endl;
			return 0;
		}
		else mn_seen += i.second;
	if(mn_seen != cur_neg_sum || mn_seen < mn_neg_sum){
		cout << "No" << endl;
		return 0;
	}
	cout << "Yes" << endl;
	return 0;
}

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

void fail(){
    cout << "No" << endl;
    exit(0);
}

int main(){
    int N;
    cin >> N;
    vector<pair<int, int>> task_p, task_n;
    for(int i=0; i<N; i++){
        string S;
        cin >> S;
        int s = 0, mn = 0;
        for(char c : S){
            s += (c == '(' ? 1 : -1);
            mn = min(mn, s);
        }
        int a = -mn, b = s;
        (b >= 0 ? task_p : task_n).emplace_back(a, b);
    }
    sort(task_p.begin(), task_p.end());
    int R = 0;
    for(auto& p : task_p){
        if(R < p.first) fail();
        R += p.second;
    }
    sort(task_n.begin(), task_n.end(), [](auto a , auto b){ return a.first+a.second > b.first+b.second; });
    for(auto& p : task_n){
        if(R < p.first) fail();
        R += p.second;
    }
    if(R) fail();
    cout << "Yes" << endl;
    return 0;
}


#include <bits/stdc++.h>
#define rep(i, n) for(int i= 0; i < (n); i++)
using ll= long long int;
using namespace std;
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; }
ll mod= 1e9 + 7;

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

#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int>   II;
typedef vector< II >      VII;
typedef vector<int>     VI;
typedef vector< VI > 	VVI;
typedef long long int 	LL;
typedef vector<LL> 		VL;
typedef unsigned long long int ULL;

#define PB push_back
#define MP make_pair
#define F first
#define S second
#define SZ(a) (int)(a.size())
#define ALL(a) a.begin(),a.end()
#define SET(a,b) memset(a,b,sizeof(a))
#define LET(x,a) __typeof(a) x(a)

#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
//Works for forward as well as backward iteration

#define gu getchar
#define pu putchar
#define si(n) cin>>n
#define dout(n) cout<<n<<"\n"
//# define M_PI           3.14159265358979323846264338327950288

#define DRT() int t; si(t); while(t--)

#define PlUSWRAP(index,n) index = (index+1)%n		//index++; if(index>=n) index=0
#define MINUSWRAP(index,n) index = (index + n -1)%n 	//index--; if(index<0) index=n-1
#define ROUNDOFFINT(d) d = (int)((double)d + 0.5)	//Round off d to nearest integer

#define FLUSHN while(gu()!='\n')
#define FLUSHS while(gu()!=' ')

#define TRACE

#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
	cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
	const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif

#define off ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)

// set_name.find_by_order(k) It returns to an iterator to the kth element (counting from zero) in the set in O(logn) time
// set_name.order_of_key(k) It returns to the number of items that are strictly smaller than our item k in O(logn) time.

int main() {
	// #ifndef ONLINE_JUDGE
 //    freopen("../input.txt", "r", stdin);
 //    freopen("../output.txt", "w", stdout);
	// #endif
	srand(chrono::steady_clock::now().time_since_epoch().count());
	off;
	LL n;
	cin>>n;
	if(n == 1){
		cout<<"Hello World";
	}
	else{
		LL a,b;
		cin>>a>>b;
		cout<<a+b;
	}

  	return 0;
}


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

using str = string;
using ss = stringstream;

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(0);

    int n;
    str s,t;
    cin>>n>>s>>t;

    int ans=2*n;

    for(int i=n;i>0;i--)
    {
        bool c=true;
        for(int j=0;j<i;j++)if(t[j]!=s[j+n-i]){c=false;break;}
        if(c){ans=n+(n-i);break;}
    }

    cout<<ans<<"\n";

    return 0;
}

//using class
#include<iostream>
#include<cmath>
#include<cstdio>
using namespace std;

class Point{
  public: //以下、外部からaccess可能
  double x,y; //member

  Point(double xx,double yy){ //コンストラクタ
    x = xx;
    y = yy;
  }
};

double getDistance(Point p1, Point p2){
  return sqrt(pow(p1.x - p2.x, 2) + pow(p1.y - p2.y, 2));
}

int main(){
  Point p1(0,0), p2(0,0); //変数宣言
  //コンストラクタによって座標指定して初期化

  cin >> p1.x >> p1.y >> p2.x >> p2.y; //public access可

  printf ("%lf", getDistance(p1, p2) );

  return 0;
}


#include<bits/stdc++.h>
#define ls u*2
#define rs u*2+1
#define mid (l+r)/2
#define int long long
using namespace std;
const int N=3e5;
int n,m,s,t;
int x[N];
int bj[N*2],lmin[N*2],rmin[N*2];
inline int read(){
	char c=getchar();
	register int s=0;
	while(c<'0'||c>'9')c=getchar();
	while(c>='0'&&c<='9'){
		s=s*10+c-'0';
		c=getchar();
	}return s;
}
inline void pushdown(register int u){
	if(!bj[u])return ;
	bj[ls]+=bj[u];
	bj[rs]+=bj[u];
	lmin[ls]+=bj[u];
	rmin[ls]+=bj[u];
	lmin[rs]+=bj[u];
	rmin[rs]+=bj[u];
	bj[u]=0;
	return ;
}
void update(int u){
	lmin[u]=min(lmin[ls],lmin[rs]);
	rmin[u]=min(rmin[ls],rmin[rs]);
}
int query(int u,int l,int r,int L,int R)
{
	if(L>R)return 191919810889;
	if(L<=l&&R>=r){
		return lmin[u];
	}
	pushdown(u);
	int minn=1919191989881;
	if(L<=mid)minn=query(ls,l,mid,L,R);
	if(R>mid)minn=min(minn,query(rs,mid+1,r,L,R));
	update(u);
	return minn;
}
int ask(int u,int l,int r,int L,int R)
{
	if(L>R)return 191919818809;
	if(L<=l&&R>=r){
		return rmin[u];
	}
	pushdown(u);
	int minn=1919191988819;
	if(L<=mid)minn=ask(ls,l,mid,L,R);
	if(R>mid)minn=min(minn,ask(rs,mid+1,r,L,R));
	update(u);
	return minn;
}
void add(int u,int l,int r,int k,int summ){
	if(l==r){

		lmin[u]=min(lmin[u],summ-l);
		rmin[u]=min(rmin[u],summ+l);
	//	cout<<"hh:"<<rmin[u]<<endl;
		return ;
	}
	pushdown(u);
	if(k<=mid)add(ls,l,mid,k,summ);
	if(k>mid)add(rs,mid+1,r,k,summ);
	update(u);
}
int modify(int u,int l,int r){
	if(l==r){
		return rmin[u]-l;
	}
	pushdown(u);
	int minn=191919818880;
	minn=min(modify(ls,l,mid),modify(rs,mid+1,r));
	return minn;
}
signed main()
{
	n=read();m=read();s=read();t=read();
	x[0]=s;
	for(register int i=1;i<=m;i++){x[i]=read();}
	memset(lmin,10,sizeof(lmin));
	memset(rmin,10,sizeof(rmin));
	add(1,1,n,t,0);
	for(int i=1;i<=m;i++){
		int af=min(query(1,1,n,1,x[i])+x[i],ask(1,1,n,x[i],n)-x[i]);
//		cout<<af<<endl;
		bj[1]+=abs(x[i]-x[i-1]);
		lmin[1]+=abs(x[i]-x[i-1]);
		rmin[1]+=abs(x[i]-x[i-1]);
		add(1,1,n,x[i-1],af);
	}
	printf("%lld",modify(1,1,n));
	return 0;
}

#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <algorithm>
typedef long long ll ;
#define rep(i, a, b) for (int i = a; i <= b; ++ i)
const int N = 2e5 + 5 ;
const ll inf = 1e17 + 7 ;
using namespace std ;

int n, m, A, B, x[N] ;
ll bit[2][2][N], dist[N], f[2][N] ;

void put(int cx, int cy, int x, ll y) {
	for ( ; x <= n ; x += x & (- x)) bit[cx][cy][x] = min(bit[cx][cy][x], y) ;
}

ll get(int cx, int cy, int x) {
	ll res = inf ;
	for ( ; x ; x -= x & (- x)) res = min(res, bit[cx][cy][x]) ;
	return res ;
}

int main() {
	scanf("%d%d%d%d", &n, &m, &A, &B) ;
	rep(i, 1, m) scanf("%d", &x[i]) ;
	rep(i, 0, 1) rep(j, 0, 1) rep(k, 1, n) bit[i][j][k] = inf ;
	rep(i, 2, m) dist[i] = dist[i - 1] + abs(x[i] - x[i - 1]) ;
	f[0][0] = abs(B - x[1]), f[1][0] = abs(A - x[1]) ;
	put(0, 0, A, f[0][0] - dist[1] - A), put(0, 1, n - A + 1, f[0][0] - dist[1] + A) ;
	put(1, 0, B, f[1][0] - dist[1] - B), put(1, 1, n - B + 1, f[1][0] - dist[1] + B) ;
	rep(i, 1, m - 1) {
		f[0][i] = min(get(1, 0, x[i + 1]) + dist[i] + x[i + 1], get(1, 1, n - x[i + 1] + 1) + dist[i] - x[i + 1]) ;
		f[1][i] = min(get(0, 0, x[i + 1]) + dist[i] + x[i + 1], get(0, 1, n - x[i + 1] + 1) + dist[i] - x[i + 1]) ;
		put(0, 0, x[i], f[0][i] - dist[i + 1] - x[i]), put(0, 1, n - x[i] + 1, f[0][i] - dist[i + 1] + x[i]) ;
		put(1, 0, x[i], f[1][i] - dist[i + 1] - x[i]), put(1, 1, n - x[i] + 1, f[1][i] - dist[i + 1] + x[i]) ;
	}
	ll ans = inf ;
	rep(i, 0, m - 1) ans = min(ans, min(f[0][i], f[1][i]) + dist[m] - dist[i + 1]) ;
	printf("%lld\n", ans) ;
	return 0 ;
}


#include <cstdio>
#include <iostream>
#include <cmath>
#include <cstring>
#include <sstream>
#include <algorithm>
#include <cstdlib>
#include <map>
#include <queue>
#include <utility>
#include <vector>
#include <set>
#include <memory.h>
#include <iomanip>
#include <bitset>
#include <list>
#include <stack>
#include <deque>
#include <numeric>

using namespace std;

#define mod 1000000007

// seiyaku[i][0] : 値iは行seiyaku[i][0]で最大値でないといけない
// seiyaku[i][1] : 値iは列seiyaku[i][0]で最大値でないといけない
int seiyaku[1000001][2] = {};

int main()
{
	int n, m;
	cin >> n >> m;
	long long int ans = 1;
	for(int i = 1; i <= n; i++){
		int a;
		cin >> a;
		if(seiyaku[a][0] > 0) ans = 0;
		else seiyaku[a][0] = i;
	}
	for(int i = 1; i <= m; i++){
		int b;
		cin >> b;
		if(seiyaku[b][1] > 0) ans = 0;
		else seiyaku[b][1] = i;
	}
	// i行目にはすでに最大値が埋められている
	bool alreadymax_g[1001];
	// i列目にはすでに最大値が埋められている
	bool alreadymax_r[1001];
	for(int i = 1; i <= n; i++){
		alreadymax_g[i] = false;
	}
	for(int i = 1; i <= m; i++){
		alreadymax_r[i] = false;
	}

	for(int i = n * m; i>= 1; i--){
		int g = seiyaku[i][0];
		int r = seiyaku[i][1];
		if(g > 0 && r > 0){
			// 行と列どちらにも制約がある(最大値となる)場合
			// g行目r列目にiを埋めないといけない
			if(alreadymax_g[g] || alreadymax_r[r]){
				ans = 0;
			} else {
				alreadymax_g[g] = true;
				alreadymax_r[r] = true;
			}
		} else if(g > 0 && r == 0){
			// 行にのみ制約がある場合
			// g行目に埋めることは確定しているが、列は確定していない
			if(alreadymax_g[g]){
				// g行目にすでに最大値が埋まっていたらアウト
				ans = 0;
			} else {
				alreadymax_g[g] = true;
				// g行目で制約を気にせず入れられるマスの数を求める
				int tmp = 0;
				for(int j = 1; j <= m; j++){
					if(alreadymax_r[j]) tmp++;
				}
				ans = (ans * tmp) % mod;
			}
		} else if(g == 0 && r > 0){
			// 列のみに制約がある場合
			// 上と同様
			if(alreadymax_r[r]){
				ans = 0;
			} else {
				alreadymax_r[r] = true;
				int tmp = 0;
				for(int j = 1; j <= n; j++){
					if(alreadymax_g[j]) tmp++;
				}
				ans = (ans * tmp) % mod;
			}
		} else {
			// 行にも列にも制約がない場合
			int tmp_g = 0;
			int tmp_r = 0;
			for(int j = 1; j <= n; j++){
				if(alreadymax_g[j]) tmp_g++;
			}
			for(int j = 1; j <= m; j++){
				if(alreadymax_r[j]) tmp_r++;
			}
			ans =(ans * (tmp_r * tmp_g - (n * m - i))) % mod;
		}
	}
	cout << ans << endl;
}

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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    string s;
    cin >> n >> s;
    vector<int> ans;
    for(int i = 0; i < 4; i++){
    	ans.resize(n);
    	ans[0] = i%2;
    	ans[1] = i/2;
    	for(int j = 1; j < n-1; j++){
    		if(s[j] == 'o'){
    			if(ans[j] == 0) ans[j+1] = ans[j-1];
    			else ans[j+1] = !ans[j-1];
    		}
    		else{
    			if(ans[j] == 0) ans[j+1] = !ans[j-1];
    			else ans[j+1] = ans[j-1];
    		}
    	}
    	if(s[0] == 'o'){
    		if((ans[0] == 0) ^ (ans[1] == ans.back())) continue;
    	}
    	else{
    		if((ans[0] == 0) ^ (ans[1] != ans.back())) continue;
    	}
    	if(s.back() == 'o'){
    		if((ans.back() == 0) ^ (ans[0] == ans[n-2])) continue;
    	}
    	else{
    		if((ans.back() == 0) ^ (ans[0] != ans[n-2])) continue;
    	}
    	for(int j = 0; j < n; j++){
    		cout << "SW"[ans[j]];
    	}
    	cout << endl;
    	return 0;
    }
    cout << -1 << endl;
    return 0;
}


#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cassert>
#include <vector>
#include <string>
#include <cmath>
#include <map>
using namespace std;

const int MAX= 10000100;

#define loop(i,a,b) for(int i = a ; i < b ; i ++)
#define rep(i,a) loop(i,0,a)
#define all(a) (a).begin(),(a).end()
#define ll long long int
#define gcd(a,b) __gcd(a,b)

int GCD(int a, int b) {if(!b) return a; return gcd(b, a%b);}
int lcm(int a, int b) {return a*b / gcd(a, b);}

int main(void){
  string str;
  while(cin>>str){
    vector<int> card;
    vector<int> cnt(13,0);
    for(int i = 0 ; i < str.size() ; i ++){
      if('1' <= str[i] && str[1] <= '9'){
	if('0' <= str[i + 1] && str[i + 1] <= '9'){
	  int num = 10 + str[i + 1] - '0';
	  card.push_back(num);
	  cnt[--num] ++;
	  i ++;
	}else{
	  int num = str[i] - '0';
	  card.push_back(num);
	  cnt[--num] ++;
	}
      }
    }
    sort(card.begin(),card.end());
    int ans[2][2] = {0,0,0,0};
    int c1,c2;
    c1 = c2 = 0;
    bool straight = false;
    rep(i,cnt.size()){
      if(cnt[i] == 1 &&
	 cnt[i + 1] == 1 &&
	 cnt[i + 2] == 1 &&
	 cnt[i + 3] == 1 &&
	 cnt[i + 4] == 1){
	straight = true;
	break;
      }
      if(cnt[i] > 1 && c1 == 0)
	c1 = cnt[i];
      else if(cnt[i] > 1)
	c2 = cnt[i];
    }
    if(straight)
      cout<<"straight";
    else if(c1 == 5)
      cout<<"five card";
    else if(c1 == 4 || c2 == 4)
      cout<<"four card";
    else if((c1 == 3 && c2 == 2) ||
	    (c1 == 2 && c2 == 3))
      cout<<"full house";
    else if(c1 == 3)
      cout<<"three card";
    else if(c1 == 2 && c2 == 2)
      cout<<"two pair";
    else if(c1 == 2)
      cout<<"one pair";
    else if(cnt[ 9] == 1 &&
	    cnt[10] == 1 &&
	    cnt[11] == 1 &&
	    cnt[12] == 1 &&
	    cnt[ 0] == 1)
      cout<<"straight";
    else
      cout<<"null";
    cout<<endl;

    }
}


#include<cstdio>
#include<algorithm>
#define fo(i,a,b) for(i=a;i<=b;i++)
using namespace std;
typedef long long ll;
const int maxn=100000+10;
int fa[maxn],co[maxn];
bool bz[maxn],pd[maxn];
int i,j,k,l,r,t,n,m,cnt;
ll ans;
int getfa(int x){
    if (!fa[x]) return x;
    int t=getfa(fa[x]);
    co[x]^=co[fa[x]];
    return fa[x]=t;
}
int main(){
    scanf("%d%d",&n,&m);
    fo(i,1,m){
        scanf("%d%d",&j,&k);
        bz[j]=1;bz[k]=1;
        l=getfa(j);r=getfa(k);
        if (l<r){
            swap(l,r);
            swap(j,k);
        }
        if (l==r&&co[j]==co[k]) pd[l]=1;
        if (l==r) continue;
        pd[r]|=pd[l];
        fa[l]=r;
        co[l]=co[j]^co[k]^1;
    }
    fo(i,1,n)
        if (!bz[i]) cnt++;
    ans=(ll)cnt*(n-cnt)*2+(ll)cnt*cnt;
    cnt=0;
    fo(i,1,n)
        if (bz[i]&&!fa[i]) cnt++;
    ans+=(ll)cnt*cnt;
    cnt=0;
    fo(i,1,n)
        if (bz[i]&&!fa[i]&&!pd[i]) cnt++;
    fo(i,1,n)
        if (bz[i]&&!fa[i]&&!pd[i]) ans+=(ll)cnt;
    printf("%lld\n",ans);
}

#include <bits/stdc++.h>
using namespace std;
int col[100005];
vector<int> v[100005];
bool dfs(int node,int c)
{
	if (col[node]!=-1)
	return (col[node]==c);
	col[node]=c;
	bool ok=1;
	for (int u:v[node])
	ok&=dfs(u,!c);
	return ok;
}
int main()
{
	int n,m,c=0,b=0;
	scanf("%d%d",&n,&m);
	while (m--)
	{
		int a,b;
		scanf("%d%d",&a,&b);
		v[a].push_back(b);
		v[b].push_back(a);
	}
	memset(col,-1,sizeof(col));
	int nn=n;
	long long ans=0;
	for (int i=1;i<=n;i++)
	{
		if (v[i].empty())
		{
			ans+=2*nn-1;
			nn--;
			continue;
		}
		if (col[i]==-1)
		{
			c++;
			b+=dfs(i,0);
		}
	}
	printf("%lld",ans+1LL*c*c+1LL*b*b);
}


#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef long double ld;
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i,n) for(int i=n; i>-1; --i)
#define ALL(a) (a).begin(),(a).end()
#define FILL(a,n,x); REP(i,(n)){ (a)[i]=(x); }
#define CINA(a,n); REP(i,(n)){ cin >> (a)[i]; }
#define FILL2(a,n,m,x); REP(i,(n)){ REP(j,(m)){(a)[i][j]=(x);} }
#define CINA2(a,n,m); REP(i,(n)){ REP(j,(m)){cin >> (a)[i][j];} }
#define Liny "Yes\n"
#define Linn "No\n"
#define LINY "YES\n"
#define LINN "NO\n"

//cout << setfill('0') << right << setw(4) << 12; // "0012"
int keta(ll x){ if(x<10){return 1;} else{return keta(x/10) + 1;}}
int keta_wa(ll x){ if(x<10){return x;} else{return keta_wa(x/10) + x%10;} }
int ctoi(char c){ return ( (c>='0' && c<='9')? c - '0': 0 );}
int __stoi(string s){ return atoi(s.c_str()); }
ll sum(ll a[],ll N){ return accumulate(a,a+N,0LL);}
ll gcd(ll a,ll b){if(a<b)swap(a,b); return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){if(a<b){swap(a,b);} return a/gcd(a,b)*b;}
template<class T> void chmax(T& a, T b){ if(a<b){a=b;} }
template<class T> void chmin(T& a, T b){ if(a>b){a=b;} }
template<class T> bool isIn(T a,vector<T> v){ for(T x:v){ if(a==x){return true;}} return false;}
string strReplace(string s,string target, string replacement){
    if (!target.empty()) {
      std::string::size_type pos = 0;
      while ((pos = s.find(target, pos)) != std::string::npos) {
        s.replace(pos, target.length(), replacement);
        pos += replacement.length();
      }
    }
    return s;
}
const ll MOD = 998244353;
#define pii pair<int,int>
#define pll pair<ll,ll>
#define MP make_pair

struct UnionFind{
    vector<ll> par,s,b,w;
    UnionFind(ll N) : par(N),s(N),b(N),w(N){
        REP(i,N){
            par[i] = i;
            b[i] = 0;
            w[i] = 0;
            s[i] = 0;
        }
    }
    int root(int x){
        if(par[x]==x){ return x; }
        else{
          par[x]= root(par[x]);
          return par[x];
        }
    }
    void unite(int x, int y){
        int rx = root(x);
        int ry = root(y);
        if( rx!=ry ){
            par[rx] = ry;
            s[ry] += s[rx];
            w[ry] += w[rx];
            b[ry] += b[rx];
        }
    }

    void coloring(int x,char c){
        int rx = root(x);
        if(c=='.'){
            w[rx] += 1;
        }else{
            b[rx] += 1;
        }
    }
    ll solve(int rx){
        return w[rx]*b[rx];
    }
};

int main(){
    int H,W; cin>>H>>W;
    string board[H]; CINA(board,H);
    UnionFind uf(H*W);
    REP(i,H){
        REP(j,W){
            uf.coloring(i*W+j,board[i][j]);
        }
    }
    REP(i,H){
        REP(j,W){
            if(i+1<H){
                if(board[i][j]!=board[i+1][j]){
                    uf.unite(i*W+j,(i+1)*W+j);
                }
            }
            if(j+1<W){
                if(board[i][j]!=board[i][j+1]){
                    uf.unite(i*W+j,i*W+j+1);
                }

            }
        }
    }
    ll ans = 0;
    map<int,int> mp;
    REP(x,H*W){
        int rx = uf.root(x);
        if(mp[rx]==0){
            ++mp[rx];
            ans += uf.solve(rx);
        }

    }
    cout << ans << "\n";

}

#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <fstream>
#include <numeric>
using namespace std;
typedef long long int ll;

#define EPS (1e-7)
#define INF 1e18
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))
#define PI (acos(-1))

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

int main() {
    int a, b;
    cin >> a >> b;
    cout << (a * b) << endl;

    return 0;
}


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

int main()
{
	double a;
	double n;
	double max,min,sum;

	cin>>n;
	sum=0;
	max=-1000000;
	min=1000000;
	for( int i=0; i<n; i++ ) {
		cin>>a;
		sum+=a;
		if( max < a ) {
			max=a;
		}
		if( a < min ) {
			min=a;
		}
	}

	cout <<setprecision(12)<<min<<" "<<max<<" "<<sum<<endl;
    return 0;
}

#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <functional>
#include <queue>
#include <set>
#include <map>
#include <numeric>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cctype>

#define rep(i, a) REP(i, 0, a)
#define REP(i, a, b) for(int i = a; i < b; ++i)

typedef long long ll;
typedef unsigned long long ull;
typedef std::pair<int, int> P;
typedef std::pair<P, int> PP;
const double esp = 1e-9;
const int infi = (int)1e+9 + 10;
const ll infll = (ll)1e+17 + 10;

int n;
int a[10001];

int main(){
	std::cin >> n;
	rep(i, n)std::cin >> a[i];
	std::cout << *std::min_element(a, a + n) << " " << *std::max_element(a, a + n) << " " << std::accumulate(a, a + n, 0ll) << std::endl;
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define ALL(v) (v).begin(), (v).end()
using ll = long long;
using P = pair<int, int>;
constexpr int INF = 1e9;
constexpr long long LINF = 1e18;
constexpr long long MOD = 1e9 + 7;

void solve() {
    int n;
    cin >> n;
    ll a[n];
    rep(i, n) {
        cin >> a[i];
    }
    string s;
    cin >> s;
    reverse(a, a + n);
    reverse(ALL(s));
    vector<ll> bs;
    rep(i, n) {
        for (auto b : bs) {
            a[i] = min(a[i], a[i] ^ b);
        }
        if (s[i] == '0') {
            if (a[i] != 0) bs.emplace_back(a[i]);
        } else {
            if (a[i]) {
                cout << 1 << endl;
                return;
            }
        }
    }
    cout << 0 << endl;
}

signed main() {
    int tt;
    cin >> tt;
    while (tt--) {
        solve();
    }
    return 0;
}

#include <bits/stdc++.h>

#define debug(...) fprintf(stderr, __VA_ARGS__)

#ifndef AT_HOME
#define getchar() IO::myGetchar()
#define putchar(x) IO::myPutchar(x)
#endif

namespace IO {
	static const int IN_BUF = 1 << 23, OUT_BUF = 1 << 23;

	inline char myGetchar() {
		static char buf[IN_BUF], *ps = buf, *pt = buf;
		if (ps == pt) {
			ps = buf, pt = buf + fread(buf, 1, IN_BUF, stdin);
		}
		return ps == pt ? EOF : *ps++;
	}

	template<typename T>
	inline bool read(T &x) {
		bool op = 0;
		char ch = getchar();
		x = 0;
		for (; !isdigit(ch) && ch != EOF; ch = getchar()) {
			op ^= (ch == '-');
		}
		if (ch == EOF) {
			return false;
		}
		for (; isdigit(ch); ch = getchar()) {
			x = x * 10 + (ch ^ '0');
		}
		if (op) {
			x = -x;
		}
		return true;
	}

	inline int readStr(char *s) {
		int n = 0;
		char ch = getchar();
		for (; isspace(ch) && ch != EOF; ch = getchar())
			;
		for (; !isspace(ch) && ch != EOF; ch = getchar()) {
			s[n++] = ch;
		}
		s[n] = '\0';
		return n;
	}

	inline void myPutchar(char x) {
		static char pbuf[OUT_BUF], *pp = pbuf;
		struct _flusher {
			~_flusher() {
				fwrite(pbuf, 1, pp - pbuf, stdout);
			}
		};
		static _flusher outputFlusher;
		if (pp == pbuf + OUT_BUF) {
			fwrite(pbuf, 1, OUT_BUF, stdout);
			pp = pbuf;
		}
		*pp++ = x;
	}

	template<typename T>
	inline void print_(T x) {
		if (x == 0) {
			putchar('0');
			return;
		}
		static int num[40];
		if (x < 0) {
			putchar('-');
			x = -x;
		}
		for (*num = 0; x; x /= 10) {
			num[++*num] = x % 10;
		}
		while (*num){
			putchar(num[*num] ^ '0');
			--*num;
		}
	}

	template<typename T>
	inline void print(T x, char ch = '\n') {
		print_(x);
		putchar(ch);
	}

	inline void printStr_(const char *s, int n = -1) {
		if (n == -1) {
			n = strlen(s);
		}
		for (int i = 0; i < n; ++i) {
			putchar(s[i]);
		}
	}

	inline void printStr(const char *s, int n = -1, char ch = '\n') {
		printStr_(s, n);
		putchar(ch);
	}
}
using namespace IO;

const int N = 205;

int n;
long long a[N];
char s[N];

long long B[64];

bool insert(long long x) {
	for (int i = 59; ~i; --i) {
		if (x >> i & 1) {
			if (B[i]) {
				x ^= B[i];
			} else {
				B[i] = x;
				return true;
			}
		}
	}
	return false;
}

void solve() {
	read(n);
	for (int i = 1; i <= n; ++i) {
		read(a[i]);
	}
	for (int i = 0; i < 60; ++i) {
		B[i] = 0;
	}
	readStr(s + 1);
	for (int i = n; i; --i) {
		if (s[i] == '0') {
			insert(a[i]);
		} else {
			if (insert(a[i])) {
				print(1);
				return;
			}
		}
	}
	print(0);
}

int main() {
	int T = 1;
	read(T);
	while (T--) {
		solve();
	}
}


#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
using namespace std;
const int N=100005;
int n,a[5][N],i,j,k,x,y,b[N],c[2];
int main()
{
	scanf("%d",&n);
	for(i=1;i<=3;++i)
		for(j=1;j<=n;++j)
			scanf("%d",a[i]+j);
	for(i=1;i<=n;++i)
	{
		x=y=a[1][i];
		for(j=2;j<=3;++j)
			x=max(x,a[j][i]),y=min(y,a[j][i]);
		if(x-y!=2||y+1!=a[2][i])
		{
			printf("No");
			return 0;
		}
		b[i]=x/3;
		if(a[1][i]!=y)
			c[i&1]=!c[i&1];
		if((x/3-i)%2)
		{
			printf("No");
			return 0;
		}
	}
	for(i=1;i<=n;++i)
	while(i!=b[i])
	{
		swap(b[i],b[b[i]]);
		c[i&1^1]=!c[i&1^1];
	}
	if(c[0]||c[1])
		printf("No");
	else
		printf("Yes");
	return 0;
}

#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REP1(i,a,b) for (int i = a; i <= (int)(b); i++)
using namespace std;
const int MOD=998244353;
int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n;
    cin >> n;
    vector<int> c(n),d(n);
    REP(i,n) cin >> d[i], c[d[i]]++;
    if ( d[0]!=0 || c[0]>1 ) { cout << 0 << '\n'; return 0; }
    int ans=1;
    REP1(i,1,n-1) {
        if ( c[i-1]==0 && c[i]==0 ) continue;
        REP(j,c[i]) ans=(long long)ans*c[i-1]%MOD;
    }
    cout << ans << '\n';
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

int main()
{
  string s;
  cin>>s;
  int c = 0;
  for (char c1 : s) if (c1 == 'R') c++;
  if (c != 2) cout << c << '\n';
  else if (s[1] == 'S') cout << 1 << '\n';
  else cout << '2' << '\n';
  return 0;
}

#include <iostream>

using namespace std;

int main()
{
    string S;
    cin>>S;
    char a=S[0]=='R';
     char b=S[1]=='R';
      char c=S[2]=='R';

     if(a&b&c)
     {
         cout<<"3";
     }
     else if(a&b||b&c)
     {
         cout<<"2";
     }
     else if(a|b|c)
     {
         cout<<"1";

     }
     else
     {

    cout<<"0";
     }
    return 0;
    }


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

typedef long long ll;
const int mod=1e9+7;

int main(){
    int n,x,a;
    while(~scanf("%d%d%d",&n,&x,&a)){
        ll ans=0;
        if(a>x)
            ans+=a-x,a=x;
        while(--n){
            int b;
            scanf("%d",&b);
            if(a+b>x)
                ans+=a+b-x,a=x-a;
            else
                a=b;
        }
        printf("%lld\n",ans);
    }
    return 0;
}

#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vint;
typedef vector<double> vd;
typedef vector<ll> vll;
typedef vector<string> vstr;
typedef vector<vector<int>> vvint;
typedef vector<pair<int, int>> vpii;
typedef vector<pair<ll, ll>> vpll;
typedef priority_queue<int, vector<int>, greater<int>> spqint; //小さい順に取り出し
typedef priority_queue<ll, vector<ll>, greater<ll>> spqll;     //小さい順に取り出し
typedef priority_queue<int, vector<int>, less<int>> bpqint;    //大きい順に取り出し
typedef priority_queue<ll, vector<ll>, less<ll>> bpqll;        //大きい順に取り出し

#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, a, b) for (int i = (int)a; i < (int)b; i++)
#define IREP(i, v) for (auto i = (v).begin(); i != (v).end(); i++)
#define FI first
#define SE second
#define MP make_pair
#define MT make_tuple
#define PB push_back
#define PF push_front
#define TS to_string
#define BS binary_search
#define LB lower_bound
#define UB upper_bound
#define NP next_permutation
#define ALL(v) (v).begin(), (v).end()
#define SZ(x) (ll) x.size()
#define SP(x) setprecision((ll)x)

int INF = 1e9;
int NIL = -1;
ll MOD = 1000000007;
ll LINF = 1e18;
double EPS = 1e-9;
double PI = M_PI;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -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; }     //最小公倍数

void yes(){ cout << "Yes" << endl;}
void no(){ cout << "No" << endl;}
//-----------------------------------------

//-----------------------------------------
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    std::chrono::system_clock::time_point start,end;
    start = std::chrono::system_clock::now();
    int n ;
    ll x ;
    cin >> n >>  x ;
    vll a(n+1,0) ;
    REP(i,n){
        cin >> a[i+1] ;
    }
    ll ans = 0 ;
    FOR(i,1,n+1){
        ll tmp = max((a[i]+a[i-1]-x),(ll)0) ;
        ans += tmp ;
        a[i] -= tmp ;
    }
    cout << ans <<endl;

    end = std::chrono::system_clock::now();
    auto elapsed = std::chrono::duration_cast< std::chrono::milliseconds >(end - start).count();
    //std::cout << elapsed <<"ms"<< std::endl;

    return 0;
}


#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "math.h"
#include "utility"
#include "string"
#include "map"
#include "unordered_map"
#include "iomanip"
#include "random"

using namespace std;
const long long int MOD = 1000000007;

int N, M;

int main() {
	ios::sync_with_stdio(false);
	cin >> N >> M;
	while (N) {
		int num[1001];
		int ans = 0;
		set<int>F;
		set<int>S;
		for (int i = 0; i < N; i++)cin >> num[i];
		F.insert(0);
		for (int i = 0; i < N/2; i++) {
			F.insert(num[i]);
			for (int j = 0; j < N/2; j++) {
				F.insert(num[i] + num[j]);
			}
		}
		S.insert(0);
		for (int i = N/2; i < N; i++) {
			S.insert(num[i]);
			for (int j = N/2; j < N; j++) {
				S.insert(num[i] + num[j]);
			}
		}
		set<int>::reverse_iterator ritr = S.rbegin();
		for (auto i : F) {
			if (ritr == S.rend())break;
			while ((i + *ritr) > M) {
				++ritr;
				if (ritr ==S.rend())break;
			}
			if(ritr!=S.rend())	ans = max(ans, i + *ritr);
		}
		cout << ans << endl;
		cin >> N >> M;
	}
	return 0;
}

#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int n,m,a[2000];
vector<int> t;
int main(){
  a[0]=0;
  while(cin>>n>>m&&n&&m){
    t.clear();
    for(int i=1;i<=n;i++)cin>>a[i];
    for(int i=0;i<n;i++){
      for(int j=i;j<=n;j++){
	t.push_back(-(a[i]+a[j]));
      }
    }
    sort(t.begin(),t.end());
    int ans=0;
    for(int i=0;i<(int)t.size();i++){
      int x=-t[i];
      int y=m-x;
      if(y<0)continue;
      vector<int> :: iterator it;
      it = upper_bound(t.begin(),t.end(),-y);
      if(it==t.end())continue;
      int z = *it;
      ans=max(ans,x-z);
    }
    cout<<ans<<endl;
  }
  return 0;
}


//KING NIKAN
#include <bits/stdc++.h>
using namespace std;
typedef long long ll ;
ll ans[60] ;
int main()
{
	ios::sync_with_stdio(false) ;cin.tie(0) ;cout.tie(0) ;
	ll k ;
	cin >> k ;
	cout << 50 << "\n" ;
	ll x=k/50 ;
	for(int i=0 ;i<50 ;i++)
	{
        ans[i] = x+49;
    }
    ll y = k%50;
    for(int k=0 ;k<y ;k++)
	{
        for(int i=0 ;i<50 ;i++)
		{
            if(k==i)
			{
				ans[i]+=50 ;
			}
            else
			{
				ans[i]-=1 ;
			}
        }
    }
    for(int i=0 ;i<50 ;i++)
    {
    	cout << ans[i] << " " ;
	}
	return 0 ;
}

#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
const int INF=1e9,MOD=1e9+7,ohara=1e6+10;
const ll LINF=1e18;
using namespace std;

#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(int i=(a);i<(b);i++)
#define rrrep(i,a,b) for(int i=(a);i>=(b);i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout<<(x)<<endl
#define doublecout(a) cout<<fixed<<setprecision(15)<<a<<endl;
#define Cerr(x) cerr<<(x)<<endl
#define fi first
#define se second
#define P pair<ll,ll>
#define m_p make_pair
#define V vector<ll>
#define U_MAP unordered_map<ll,ll>

ll n,cnt,ans[ohara],a,b,c,d,tmp,tmpp,m,h,w,x,y,sum,pos,k;
ld doua;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
//int dy[]={-1,0,1,-1,1,-1,0,1};
//int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"),s;
bool fl;
struct edge{int to,cost;};
ll cou[ohara];

//-------------------------↓↓↓↓↓↓------------------------

//------ 自分を天才だと信じる ------

int main(void){
        cin.tie(0);
        cout.tie(0);
    ios::sync_with_stdio(false);

    cin>>k;
    rep(i,50)ans[i]=i;
    rep(i,50){
        ans[i]+=(k/50)*50;
        cou[i]=k/50;
    }
    rep(i,k%50){
        ans[i]+=50;
        cou[i]++;
    }
    rep(i,50){
        ans[i]-=(k-cou[i]);
    }

    Cout(50);
    rep(i,50){
        if(i==49)Cout(ans[i]);
        else cout<<ans[i]<<" ";
    }
    return 0;
}


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

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

	string str2;
	int size = (int)str.size();
	str2.resize(size);
	for(int i =0; i<size;++i)
	{
		str2[size-1-i] = str[i];
	}

	cout << str2 << endl;
	return(0);
}

#include <iostream>
#include <string>
#include <algorithm>

int main(void) {
    std::string str;

    std::cin >> str;
    std::for_each(str.crbegin(), str.crend(), [](const char& ch){ std::cout << ch; });
    std::cout << std::endl;

    return 0;
}


#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<vector>
#include<string>
#include<sstream>
#include<iomanip>
#include<utility>
#include<cmath>
#include<set>
#include<list>
#include<queue>
#include<stack>
#include<map>
#include<set>
using namespace std;
typedef long long int ll;
const int MAX=100000;
const int INFTY=1<<30;

int n,col[MAX],d[MAX];
vector<pair<int,int>> Q[MAX];//target,weight

void dijkstra(int s)
{
	priority_queue<pair<int,int>> PQ;//weight,id
	for(int i=0;i<n;i++)
	{
		d[i]=INFTY;
		col[i]=0;
	}
	d[s]=0;
	PQ.push(make_pair(0,s));
	col[s]=1;

	while(!PQ.empty())
	{
		pair<int,int> f=PQ.top();PQ.pop();
		int u=f.second;
		col[u]=2;
		if(d[u]<f.first*(-1))continue;
		for(int j=0;j<Q[u].size();j++)
		{
			int v=Q[u][j].first;
			if(col[v]==2)continue;
			if(d[u]+Q[u][j].second<d[v])
			{
				d[v]=d[u]+Q[u][j].second;
				PQ.push(make_pair(d[v]*(-1),v));
				col[v]=1;
			}
		}
	}

	for(int i=0;i<n;i++)
	{
		if(d[i]==INFTY)cout<<"INF"<<endl;
		else cout<<d[i]<<endl;
	}

	return;
}

int main()
{
	cin>>n;
	int u;int m;cin>>m>>u;
	int s,t,w;
	for(int i=0;i<m;i++)
	{
		cin>>s>>t>>w;
		Q[s].push_back(make_pair(t,w));
	}
	dijkstra(u);
	return 0;
}

#define _CRT_SECURE_NO_WARNINGS
// #define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define all(c) begin(c), end(c)
#define range(i,a,b) for(int i = a; i < (int)(b); i++)
#define rep(i,b) range(i,0,b)
#define eb emplace_back
typedef long long ll;
#define int ll
auto const inf = numeric_limits<int>::max()/4;

using Weight = int;
using Capacity = int;
struct Edge {
    int src, dst; Weight weight;
    Edge(int s, int d, int w) : src(s), dst(d), weight(w) {}
};
using Edges = vector<Edge>;
using Graph = vector<Edges>;
using Array = vector<Weight>;
using Matrix = vector<Array>;

pair<vector<Weight>, bool> spfa(const Graph &g, int s){
    const Weight inf = numeric_limits<Weight>::max()/4;
    const int n = g.size(); priority_queue<int> q;
    vector<Weight> dist(n, inf); vector<int> inQ(n);
    vector<int> count(n);
    dist[s] = 0; q.emplace(s); inQ[s] = true; ++count[s];
    bool negCycle = false;
    for(int i = 0; q.size(); i++){
        int v = q.top(); q.pop(); inQ[v] = false;
        for(auto &e : g[v]){
            if(dist[v] != inf && dist[e.dst] > dist[v] + e.weight){
                dist[e.dst] = dist[v] + e.weight;
                if(!inQ[e.dst]){
                    q.emplace(e.dst); inQ[e.dst] = true; ++count[e.dst];
                    if(count[e.dst] >= n){ negCycle = true; goto END; }
                }
            }
        }
    }
 END:;
    return make_pair(dist, !negCycle);
}

signed main(){
    int V,E,r;
    while(cin >> V >> E >> r){
        Graph g(V);
        rep(i,E){
            int a,b,c;
            cin >> a >> b >> c;
            g[a].eb(a,b,c);
        }
        bool ok;
        vector<Weight> dist;
        tie(dist, ok) = spfa(g,r);
        if(ok){
            for(int i = 0; i < (int)dist.size(); i++){
                if(dist[i] == inf) cout << "INF";
                else cout << dist[i];
                cout << endl;
            }
        } else {
            cout << "NEGATIVE CYCLE" << endl;
        }
    }
}


#include <stdio.h>
#include <string.h>
#include <string>
#include <iostream>
#include <vector>
#include <sstream>
#include <memory>
#include <iomanip>

std::vector<int> parse_line(std::string const& line) {
    using namespace std;
    vector<int> result;
    istringstream s(line);
    string element;
    while (getline(s, element, ' ')) {
        stringstream buf;
        int value = 0;
        buf << element;
        buf >> value;
        result.push_back(value);
    }
    return std::move(result);
}
int main(int argc, char* argv[])
{
    using namespace std;
    while (true) {
        string line;
        getline(std::cin, line);
        auto elements = parse_line(line);
        auto length = elements[0];
        if (length == 0) break;
        vector<int> total(length + 1);
        size_t width = length + 1;
        for (size_t i = 0; i < length; ++i) {
            getline(cin, line);
            elements = parse_line(line);
            int sum = 0;
            for (size_t n = 0; n < length; ++n) {
                int val = elements[n];
                sum += val;
                total[n] += val;
                cout << setw(5) << val;
            }
            cout << setw(5) << sum << endl;
            total[length] += sum;
        }
        for (size_t i = 0; i < width; ++i) {
            cout << setw(5) << total[i];
        }
        cout << endl;
    }

    return 0;
}

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

int main()
{
	int n;

	while( cin >> n &&  n ){
		int* table = new int[ (n+1) * (n+1) ]();
		for( int i = 0; i < n; ++i ){
			int sum_col = 0;
			for( int j = 0; j < n; ++j ){
				int d;
				cin >> d;
				table[ i * (n+1) + j ] = d;
				table[ i * (n+1) + n ] += d;
				table[ n * (n+1) + j ] += d;
				table[ n * (n+1) + n ] += d;
			}
		}

		for( int i = 0; i < n+1; ++i ){
			for( int j = 0; j < n+1; ++j ){
				cout.width( 5 );
				cout << table[ i * (n+1) + j ];
			}
			cout << endl;
		}

		delete[] table;
	}
	return 0;
}


#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>

int main(void)
{
	int i, j, n;

	scanf("%d", &n);

	for (i = 1; i <= n; i++){
		if (i % 3 == 0){
			printf(" %d", i);
		}

		else{
			j = i;
			while (j > 0){
				if (j % 10 == 3){
					printf(" %d", i);
					break;
				}
					j /= 10;
			}
		}
	}
	putchar('\n');

	return 0;
}

#include<iostream>
using namespace std;

int x, i = 1;
int n;

void check_num();
void include3();
void end_check_num();

void check_num() {
	x = i;
	if (x % 3 == 0){
		cout << " " << i;
		end_check_num();
	}else include3();
}

void include3() {
	if (x % 10 == 3){
		cout << " " << i;
		end_check_num();
	}else{
		x /= 10;
		if (x)include3();
		else end_check_num();
	}
}

void end_check_num() {
	if (++i <= n) check_num();
}

int main() {
	cin >> n;
	check_num();
	cout << endl;
	char c;
	cin >> c;
}


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

long long int labs(long long int a, long long int b)
{
	return ((a>b)?a-b:b-a);
}

long long int lmin(long long int a, long long int b)
{
	return ((a>b)?b:a);
}

int main()
{
	long long int n, k, x[100001];
	cin >> n >> k;
	for (int i = 0; i < n; ++i)
	{
		cin >> x[i];
	}
	long long int ans = 1145141919;
	for (int i = k; i <= n; ++i)
	{
		ans = lmin(ans, labs(x[i-k]-x[i-1])+lmin(labs(x[i-k]),labs(x[i-1])));
	}
	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;

long long  N, K;
vector<long long> x;

long long calcTime(int i, int k){
	if(k <= 1) return 0;

	long long rt = (1L<<61), lt = (1L<<61);

	int Rk = N - i - 1; //x[i]より右にある本数
	int Lk = i;         //x[i]より左にある本数

	//右に行ってから左へ
	for(int j = K - i - 1; j <= Rk; j++){
		if(i + j >= N || j < 0) continue;
		long long t = x[i + j] - x[i]; //右の端までの時間
		t *= 2; //x[i]まで戻ってくる
		t += x[i] - x[i - (K - j - 1)];//左の端まで
		if(t < rt) rt = t;
	}

	//左に行ってから右へ
	for(int j = K- N + i; j <= Lk; j++){
		if(i < j || j < 0) continue;;
		long long t = x[i] - x[i - j]; //左の端までの時間
		t *= 2; //x[i]まで戻ってくる
		t += x[i + (K - j - 1)] - x[i];//右の端まで
		if(t < lt) lt = t;
	}
	return (long long) min(rt, lt);
}

int main(int argc, char* argv[]){
	cin >> N >> K;
	for(int i=1; i<=N; i++){
		long long u;
		cin >> u;
		x.push_back(u);
	}
	//入力はソート済だが念のためソートする
	sort(x.begin(), x.end());

	long long ans = 0;
	if(x[0] >= 0){
		ans = (long long)abs(x[K-1]);
		printf("%lld\n", ans);
		return 0;
	}
	else if(x[N-1] <= 0){
		ans = (long long)abs(x[N-K]);
		printf("%lld\n", ans);
		return 0;
	}
	int a, b;
	for(int i=0; i<N; i++){
		if(x[i] > 0){ break; }
		a = i;
	}
	for(int i=N-1; i>=0; i--){
		if(x[i] < 0){ break; }
		b = i;
	}
	long long ans_a = abs(x[a]) + calcTime(a, K);
	long long ans_b = abs(x[b]) + calcTime(b, K);
	ans = min( ans_a, ans_b);
	printf("%lld\n", ans);
	return 0;
}


#include<iostream>
#include<vector>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<queue>
#include<stack>
#include<map>
#include<set>

using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<pii,int> piii;
typedef pair<ll,ll> pll;

#define reps(i,f,n) for(int i = int(f); i <= int(n); i++)
#define rep(i,n) reps(i,0,int(n)-1)
#define rrep(i,n) for(int i = n-1; i >= 0; i--)

#define all(x) (x).begin(),(x).end()
#define X first
#define Y second

#define sz size()
#define eb emplace_back

int memo[64][64];

int main(void){
  while(1){
    int n,p;
    int pl[64] = {0};
    int ans = -1;
    int bowl;
    cin >> n >> p;
    bowl = n;
    if(n+p==0)break;
    if(memo[n][p] == 0){
      bowl = p;
      rep(i,1000000){
        if(bowl){
          bowl--;
          pl[(i%n)]++;
          if(pl[i%n] == p){ans = i%n;break;}
        }else{
          bowl = pl[i%n];
          pl[i%n] = 0;
        }
      }
      cout << ans << endl;
      memo[n][p] = ans;
    }else{
      cout << memo[n][p] << endl;
    }
  }
  return 0;
}

#include <iostream>

using namespace std;

int main(){
	int n,p;
	while(1){
		cin>>n>>p;
		if(n==0&&p==0){
			break;
		}
		int sum=p;
		int cnt=0;
		int *data;
		int state=0;
		data = new int[n];
		for(int i=0;i<n;i++){
			data[i]=0;
		}
		while(1){

			if(sum==0){
				sum+=data[cnt];
				data[cnt]=0;
			}
			else{
				data[cnt]++;
				sum--;
				if(sum==0){
					int flag=0;
					for(int i=0;i<n;i++){
						if(i==cnt)continue;
						else{
							if(data[i]>0){
								flag=1;
							}
						}
					}
					if(flag==0){
						cout<<cnt<<endl;
						state=2;
					}
				}
			}
			cnt++;
			cnt%=n;
			if(state==2)break;
		}
	}
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
int main(){
  int D,G;
  cin>>D>>G;
  vector<pair<int,int>> vec(D);
  for(int i=0;i<D;i++){
    cin>>vec.at(i).first>>vec.at(i).second;
  }
  int ans=0;
  for(int i=0;i<(1<<D);i++){
    bitset<10> bit(i);
    int point=0,ans_=0;
    for(int j=0;j<D;j++){
      if(bit.test(j)){
        point+=100*(j+1)*vec.at(j).first+vec.at(j).second;
        ans_+=vec.at(j).first;
      }
    }
    int de=D;
    while(point<G&&de>=1){
      if(de*100<=G-point&&!bit.test(de-1)){
        ans_+=min((G-point)/(de*100),vec.at(de-1).first-1);
        point+=(min((G-point)/(de*100),vec.at(de-1).first-1))*(de*100);
      }
      de--;
    }
    if(point>=G&&ans==0){
      ans=ans_;
    }
    if(point>=G&&ans_<ans) {
      ans=ans_;
    }
  }
  cout<<ans<<endl;
}

#include<cstdio>
#include<iostream>
using namespace std;
int h,w;
int l[200010],r[200010];
struct tree{
	int l,r;
	long long tag,v;
}tr[2][4*200010];
void build(int i,int l,int r)
{
	tr[0][i].l=l,tr[0][i].r=r;
	if (l==r) return;
	int mid=(l+r)>>1;
	build(i<<1,l,mid);
	build(i<<1|1,mid+1,r);
}
void update(int i,int id)
{
	tr[id][i].v=min(tr[id][i<<1].v,tr[id][i<<1|1].v);
}
void build2(int i,int l,int r)
{
	tr[1][i].l=l,tr[1][i].r=r;

	if (l==r) {tr[1][i].v=-l;return;}
	int mid=(l+r)>>1;
	build2(i<<1,l,mid);
	build2(i<<1|1,mid+1,r);
	update(i,1);
}
void add(int i,long long x,int id)
{
	//if (id==0&&tr[id][i].l==2&&tr[id][i].l==tr[id][i].r)
	//	cout<<tr[id][i].v<<" "<<x<<" tree"<<endl;
	tr[id][i].v+=x;
	tr[id][i].tag+=x;
}
void pushdown(int i,int id)
{
	if (tr[id][i].tag)
	{
		add(i<<1,tr[id][i].tag,id);
		add(i<<1|1,tr[id][i].tag,id);
		tr[id][i].tag=0;
	}
}
void modify(int i,int l,int r,long long x,int id)
{
	int L=tr[id][i].l,R=tr[id][i].r;
	if (l>R) return;
	if (l<=L&&R<=r)
	{
		add(i,x,id);
		return;
	}
	pushdown(i,id);
	int mid=(L+R)>>1;
	if (l<=mid) modify(i<<1,l,r,x,id);
	if (r>mid) modify(i<<1|1,l,r,x,id);
	update(i,id);
}
long long query(int i,int l,int r,int id)
{
	int L=tr[id][i].l,R=tr[id][i].r;
	if (l>R) return 0;
	//cout<<l<<" "<<r<<" "<<L<<" "<<R<<" "<<tr[id][i].v<<endl;
	if (l<=L&&R<=r) return tr[id][i].v;
	pushdown(i,id);
	int mid=(L+R)>>1;
	long long maxn=1e18;
	if (l<=mid) maxn=min(maxn,query(i<<1,l,r,id));
	if (r>mid) maxn=min(maxn,query(i<<1|1,l,r,id));
	return maxn;
}
int main()
{
	scanf("%d%d",&h,&w);
	for (int i=1;i<=h;i++)
		scanf("%d%d",&l[i],&r[i]);
	build(1,1,w);build2(1,1,w);
	for (int i=1;i<=h;i++)
	{
		long long other=min(0ll,r[i]+1+query(1,1,r[i],1)-query(1,r[i]+1,r[i]+1,0));
		modify(1,r[i]+1,r[i]+1,other,0);
		modify(1,r[i]+1,r[i]+1,other,1);

		modify(1,l[i],r[i],1e9,0);
		modify(1,l[i],r[i],1e9,1);

		modify(1,1,w,1,0);
		modify(1,1,w,1,1);
		long long ans=query(1,1,w,0);
		if (ans>=1e9) printf("-1\n");
		else printf("%d\n",ans);
	}
}


#include <iostream>
#include <cstdio>

using namespace std;

int table[11][11];
int main() {
  int N;
  while (cin >> N) {
    if (N == 0) break;
    for (int i = 0; i < N; i++) {
      for (int j = 0; j < N; j++) {
        cin >> table[i][j];
      }
    }
    int total = 0;
    for (int i = 0; i < N; i++) {
      int sum = 0;
      for (int j = 0; j < N; j++) {
        sum += table[i][j];
      }
      table[i][N] = sum;
      total += sum;
    }
    for (int i = 0; i < N; i++) {
      int sum = 0;
      for (int j = 0; j < N; j++) {
        sum += table[j][i];
      }
      table[N][i] = sum;
    }
    table[N][N] = total;
    for (int i = 0; i < N+1; i++) {
      for (int j = 0; j < N+1; j++) {
        printf("%5d", table[i][j]);
      }
      printf("\n");
    }
  }

  return 0;
}

#include <iostream>
#include<math.h>

using namespace std;
int smallest = 1000000;
int x, threez, N;
int main()
{
while (cin >> N && N != 0) {
    smallest = 1000000;
            for(int z = 0; pow(z, 3) <= N; z++) {
                threez = pow(z, 3);
                for(int y = 0; pow(y, 2) <= N - threez; y++) {
                    x = N - threez - pow(y, 2);
                    if (x + y + z < smallest) {
                        smallest = x + y + z;
                    }
                }
            }
            cout << smallest << endl;
}
}


#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using ull = unsigned long long;
using pll = pair<ll, ll>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(i) begin(i), end(i)

const int INF = 0x3fffffff;
const ll MINF = 0x7fffffffffff;
const ld DINF = numeric_limits<ld>::infinity();
const int MOD = 1000000007;
const int MODD = 998244353;
const ld EPS = 1e-9;
const ld PI = 3.1415926535897932;

template<class T> bool chmin(T &a, const T &b){ if(a > b){ a = b; return 1; } else return 0; }
template<class T> bool chmax(T &a, const T &b){ if(a < b){ a = b; return 1; } else return 0; }
template<class T> auto min(const T& a){ return *min_element(all(a)); }
template<class T> auto max(const T& a){ return *max_element(all(a)); }

ll gcd(ll a, ll b){ while(b){ ll c = b; b = a % b; a = c; } return a; }
ll lcm(ll a, ll b){ if(!a || !b) return 0; return a * b / gcd(a, b); }
ll pow_mod(ll n,ll k,ll m){ll r = 1;for(; k > 0;k >>= 1) {if (k & 1) r = (r * n) % m; n = (n * n) % m;}return r;}

//ここから。
int main(){
    string S;
    cin >> S;
    if(S.size() % 2==0){
        rep(i,S.size()/2){
            if(!(S.at(i*2) == 'h' && S.at(i*2 + 1)=='i')){
                cout << "No" << endl;
                return 0;
            }
        }
    }else{
        cout << "No" << endl;
        return 0;
    }
    cout << "Yes" << endl;
}

#include<bits/stdc++.h>

using namespace std;

#define LL long long
#define DD double
#define Pb push_back
#define Bp pop_back
#define Pf push_front
#define Fp pop_front
#define Ub upper_bound
#define Lb lower_bound
#define In insert
#define All(x) x.begin(), x.end()
#define mem(a, b) memset(a, b, sizeof(a))
#define fast ios_base::sync_with_stdio(0);cin.tie(0)
#define X first
#define Y second
#define mx1 10
#define mx2 110
#define mx3 1010
#define mx4 10010
#define mx5 100010
#define mx6 1000010

typedef vector<LL> Vl;
typedef vector<DD> Vd;
typedef vector<bool> Vb;
typedef vector<Vl> VVl;
typedef pair<LL, LL> Pll;
typedef pair<DD, DD> Pdd;
typedef vector<Pll> Vpl;
typedef vector<Pdd> Vpd;
typedef queue<LL> Ql;
typedef stack<LL> Sl;
typedef deque<LL> Dl;

LL _set(LL N, LL pos) {return N = N | (1 << pos);}
LL _reset(LL N, LL pos) {return N = N & ~(1 << pos);}
bool _check(LL N, LL pos) {return (bool)(N & (1 << pos));}
bool _upper(char a) {return a >= 'A' && a <= 'Z';}
bool _lower(char a) {return a >= 'a' && a <= 'z';}
bool _digit(char a) {return a >= '0' && a <= '9';}

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

///**************************DONE****************************///

int x[] = {111, 222, 333, 444, 555, 666, 777, 888, 999};

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

    for(int i = 0; i < 9; i++){
        if(x[i] >= n)
            return cout << x[i] << '\n', 0;
    }
    return 0;
}