/*
ID: justinz3
PROG: __
LANG: C++
*/
#include <string>
#include <set>
#include <stdio.h>
#include <string.h>
#include <vector>
#include <iostream>
#include <algorithm>
#include <fstream>
#include <stdlib.h>
#include <math.h>
#include <iomanip>
#include <queue>
#include <map>
#include <typeinfo>
using namespace std;

#define PI 3.1415926535897932384626

struct point
{
	int x, y;
};

struct mouse
{
	struct point start;
	int x, y;
};

int n;
vector <struct mouse> mice;
int maxx, maxy, minx, miny; // rect

double time1, time2;
double one = 1;

void intersect(int index)
{
	struct mouse in = mice[index];

	time1 = -1;
	time2 = -1;

	//cout << time1 << " " << time2 << endl;

	if(in.y == 0 and (in.start.y == maxy or in.start.y == miny))
	{
		return;
	}
	if(in.x == 0 and (in.start.x == maxx or in.start.x == minx))
	{
		return;
	}

	double time;

	if(in.x != 0)
	{
		time = (one * minx - in.start.x) / in.x; // left side

		if(time >= 0 and miny <= in.start.y + in.y * time and in.start.y + in.y * time <= maxy)
		{
			//cout << "left " << time << endl;
			if(time1 >= 0 and time != time1)
				time2 = time;
			else
				time1 = time;
		}
		time = (one * maxx - in.start.x) / in.x; // right side

		if(time >= 0 and miny <= in.start.y + in.y * time and in.start.y + in.y * time <= maxy)
		{
			//cout << "right " << time << endl;
			if(time1 >= 0 and time != time1)
				time2 = time;
			else
				time1 = time;
		}
	}

	//cout << time1 << " " << time2 << endl;

	if(in.y != 0)
	{
		time = (one * miny - in.start.y) / in.y; // bottom

		if(time >= 0 and minx <= in.start.x + in.x * time and in.start.x + in.x * time <= maxx)
		{
			//cout << "bottom " << time << endl;
			if(time1 >= 0 and time != time1)
				time2 = time;
			else
				time1 = time;
		}

		time = (one * maxy - in.start.y) / in.y; // top

		if(time >= 0 and minx <= in.start.x + in.x * time and in.start.x + in.x * time <= maxx)
		{
			//cout << "top " << time << endl;
			if(time1 >= 0 and time != time1)
				time2 = time;
			else
				time1 = time;
		}
	}

	//cout << endl;
	double temp = time2;
	if(time1 > time2 and time2 != -1)
	{
		time2 = time1;
		time1 = temp;
	}
}

bool inside_rect(int index)
{
	struct mouse in = mice[index];

	return (minx <= in.start.x and in.start.x <= maxx) and (miny <= in.start.y and in.start.y <= maxy);
	// this means that mouse will be moving and therefore moves into rect
}

int main(void)
{
	//ifstream fin("__.in");
	//ofstream fout("__.out");
	cin >> n;
	cin >> minx >> miny >> maxx >> maxy;

	struct mouse in;

	double early = 0, late = 1000100;
	for(int i = 0; i < n; i++)
	{
		cin >> in.start.x >> in.start.y >> in.x >> in.y;
		mice.push_back(in);

		intersect(i);
		//cout << inside_rect(i) << endl;
		//cout << time1 << " " << time2 << endl << endl;
		if(time1 == -1 or (time2 == -1 and not(inside_rect(i))))
		{
			cout << -1 << endl;
			return 0;
		}

		if(not(inside_rect(i)))
			early = max(early, time1);
		late = min(late, time2);
	}

	//cout << early << " " << late << endl;

	if(late < early and late != -1) // shouldn't happen
	{
		//cout << -2 << endl;
		//return 0;
		early = late;
	}

	cout << fixed << setprecision(20) << early << endl;
}


/*
ID: justinz3
PROG: __
LANG: C++
*/
#include <string>
#include <set>
#include <stdio.h>
#include <string.h>
#include <vector>
#include <iostream>
#include <algorithm>
#include <fstream>
#include <stdlib.h>
#include <math.h>
#include <iomanip>
#include <queue>
#include <map>
#include <typeinfo>
using namespace std;

#define PI 3.1415926535897932384626

struct point
{
	int x, y;
};

struct mouse
{
	struct point start;
	int x, y;
};

int n;
vector <struct mouse> mice;
int maxx, maxy, minx, miny; // rect

double time1, time2;
double one = 1;

void intersect(int index)
{
	struct mouse in = mice[index];

	time1 = -1;
	time2 = -1;

	if(in.y == 0 and (in.start.y == maxy or in.start.y == miny))
	{
		return;
	}
	if(in.x == 0 and (in.start.x == maxx or in.start.x == minx))
	{
		return;
	}

	double time;

	time = (one * minx - in.start.x) / in.x; // left side

	if(time >= 0 and miny <= in.start.y + in.y * time and in.start.y + in.y * time <= maxy)
	{
		//cout << "left " << time << endl;
		if(time1 >= 0 and time != time1)
			time2 = time;
		else
			time1 = time;
	}

	time = (one * maxx - in.start.x) / in.x; // right side

	if(time >= 0 and miny <= in.start.y + in.y * time and in.start.y + in.y * time <= maxy)
	{
		//cout << "right " << time << endl;
		if(time1 >= 0 and time != time1)
			time2 = time;
		else
			time1 = time;
	}

	time = (one * miny - in.start.y) / in.y; // bottom

	if(time >= 0 and minx <= in.start.x + in.x * time and in.start.x + in.x * time <= maxx)
	{
		//cout << "bottom " << time << endl;
		if(time1 >= 0 and time != time1)
			time2 = time;
		else
			time1 = time;
	}

	time = (one * maxy - in.start.y) / in.y; // top

	if(time >= 0 and minx <= in.start.x + in.x * time and in.start.x + in.x * time <= maxx)
	{
		//cout << "top " << time << endl;
		if(time1 >= 0 and time != time1)
			time2 = time;
		else
			time1 = time;
	}

	//cout << endl;
	double temp = time2;
	if(time1 > time2)
	{
		time2 = time1;
		time1 = temp;
	}
}

int main(void)
{
	//ifstream fin("__.in");
	//ofstream fout("__.out");
	cin >> n;
	cin >> minx >> miny >> maxx >> maxy;

	struct mouse in;

	double early = 0, late = 1000100;
	for(int i = 0; i < n; i++)
	{
		cin >> in.start.x >> in.start.y >> in.x >> in.y;
		mice.push_back(in);

		intersect(i);
		//cout << time1 << " " << time2 << endl << endl;
		if(time1 == -1 or time2 == -1)
		{
			cout << -1 << endl;
			return 0;
		}

		early = max(early, time1);
		late = min(late, time2);
	}

	if(late < early) // shouldn't happen
	{
		//cout << -2 << endl;
		return 0;
	}

	cout << fixed << setprecision(20) << early << endl;
}


/*
ID: justinz3
PROG: __
LANG: C++
*/
#include <string>
#include <set>
#include <stdio.h>
#include <string.h>
#include <vector>
#include <iostream>
#include <algorithm>
#include <fstream>
#include <stdlib.h>
#include <math.h>
#include <iomanip>
#include <queue>
#include <map>
#include <typeinfo>
using namespace std;

#define PI 3.1415926535897932384626

struct point
{
	int x, y;
};

struct mouse
{
	struct point start;
	int x, y;
};

int n;
vector <struct mouse> mice;
int maxx, maxy, minx, miny; // rect

double time1, time2;
double one = 1;

void intersect(int index)
{
	struct mouse in = mice[index];

	time1 = -1;
	time2 = -1;

	//cout << time1 << " " << time2 << endl;

	if(in.y == 0 and (in.start.y == maxy or in.start.y == miny))
	{
		return;
	}
	if(in.x == 0 and (in.start.x == maxx or in.start.x == minx))
	{
		return;
	}

	double time;

	if(in.x != 0)
	{
		time = (one * minx - in.start.x) / in.x; // left side

		if(time >= 0 and miny <= in.start.y + in.y * time and in.start.y + in.y * time <= maxy)
		{
			//cout << "left " << time << endl;
			if(time1 >= 0 and time != time1)
				time2 = time;
			else
				time1 = time;
		}
		time = (one * maxx - in.start.x) / in.x; // right side

		if(time >= 0 and miny <= in.start.y + in.y * time and in.start.y + in.y * time <= maxy)
		{
			//cout << "right " << time << endl;
			if(time1 >= 0 and time != time1)
				time2 = time;
			else
				time1 = time;
		}
	}

	//cout << time1 << " " << time2 << endl;

	if(in.y != 0)
	{
		time = (one * miny - in.start.y) / in.y; // bottom

		if(time >= 0 and minx <= in.start.x + in.x * time and in.start.x + in.x * time <= maxx)
		{
			//cout << "bottom " << time << endl;
			if(time1 >= 0 and time != time1)
				time2 = time;
			else
				time1 = time;
		}

		time = (one * maxy - in.start.y) / in.y; // top

		if(time >= 0 and minx <= in.start.x + in.x * time and in.start.x + in.x * time <= maxx)
		{
			//cout << "top " << time << endl;
			if(time1 >= 0 and time != time1)
				time2 = time;
			else
				time1 = time;
		}
	}

	//cout << endl;
	double temp = time2;
	if(time1 > time2 and time2 != -1)
	{
		time2 = time1;
		time1 = temp;
	}
}

bool inside_rect(struct mouse in)
{

	return (minx < in.start.x and in.start.x < maxx) and (miny < in.start.y and in.start.y < maxy);
	// this means that mouse will be moving and therefore moves into rect
}

bool on_edge(int index)
{
	struct mouse in = mice[index];

	return ((minx < in.start.x and in.start.x < maxx) and (in.start.y == miny or in.start.y == maxy)) or
	       ((miny < in.start.y and in.start.y < maxy) and (in.start.x == minx or in.start.x == maxx));
}

bool heading_in(int index)
{
	struct mouse in = mice[index];

	in.start.x += 0.00000000000000001 * in.x;
	in.start.y += 0.00000000000000001 * in.y;

	return inside_rect(in);
}

int main(void)
{
	//ifstream fin("__.in");
	//ofstream fout("__.out");
	cin >> n;
	cin >> minx >> miny >> maxx >> maxy;

	struct mouse in;

	double early = 0, late = 1000100;
	for(int i = 0; i < n; i++)
	{
		cin >> in.start.x >> in.start.y >> in.x >> in.y;
		mice.push_back(in);

		intersect(i);
		//cout << inside_rect(mice[i]) << endl;
		//cout << time1 << " " << time2 << endl << endl;
		if((time1 == -1 or time2 == -1) and not(inside_rect(mice[i])))
		{
			cout << -1 << endl;
			return 0;
		}

		if(not(inside_rect(mice[i])) and not(on_edge(i) and heading_in(i)))
			early = max(early, time1);
		if(time2 != -1)
			late = min(late, time2);
		else if(time2 == -1)
		{
			late = min(late, time1);
		}
		//cout << "late " << late << endl;
	}

	//cout << early << " " << late << endl;

	if(late < early and late != -1)
	{
		cout << -1 << endl;
		return 0;
		//early = late;
	}

	cout << fixed << setprecision(20) << early << endl;
}


/*
ID: justinz3
PROG: __
LANG: C++
*/
#include <string>
#include <set>
#include <stdio.h>
#include <string.h>
#include <vector>
#include <iostream>
#include <algorithm>
#include <fstream>
#include <stdlib.h>
#include <math.h>
#include <iomanip>
#include <queue>
#include <map>
#include <typeinfo>
using namespace std;

#define PI 3.1415926535897932384626

struct point
{
	int x, y;
};

struct mouse
{
	struct point start;
	int x, y;
};

int n;
vector <struct mouse> mice;
int maxx, maxy, minx, miny; // rect

double time1, time2;
double one = 1;

void intersect(int index)
{
	struct mouse in = mice[index];

	time1 = -1;
	time2 = -1;

	//cout << time1 << " " << time2 << endl;

	if(in.y == 0 and (in.start.y == maxy or in.start.y == miny))
	{
		return;
	}
	if(in.x == 0 and (in.start.x == maxx or in.start.x == minx))
	{
		return;
	}

	double time;

	if(in.x != 0)
	{
		time = (one * minx - in.start.x) / in.x; // left side

		if(time >= 0 and miny <= in.start.y + in.y * time and in.start.y + in.y * time <= maxy)
		{
			//cout << "left " << time << endl;
			if(time1 >= 0 and time != time1)
				time2 = time;
			else
				time1 = time;
		}
		time = (one * maxx - in.start.x) / in.x; // right side

		if(time >= 0 and miny <= in.start.y + in.y * time and in.start.y + in.y * time <= maxy)
		{
			//cout << "right " << time << endl;
			if(time1 >= 0 and time != time1)
				time2 = time;
			else
				time1 = time;
		}
	}

	//cout << time1 << " " << time2 << endl;

	if(in.y != 0)
	{
		time = (one * miny - in.start.y) / in.y; // bottom

		if(time >= 0 and minx <= in.start.x + in.x * time and in.start.x + in.x * time <= maxx)
		{
			//cout << "bottom " << time << endl;
			if(time1 >= 0 and time != time1)
				time2 = time;
			else
				time1 = time;
		}

		time = (one * maxy - in.start.y) / in.y; // top

		if(time >= 0 and minx <= in.start.x + in.x * time and in.start.x + in.x * time <= maxx)
		{
			//cout << "top " << time << endl;
			if(time1 >= 0 and time != time1)
				time2 = time;
			else
				time1 = time;
		}
	}

	//cout << endl;
	double temp = time2;
	if(time1 > time2 and time2 != -1)
	{
		time2 = time1;
		time1 = temp;
	}
}

bool inside_rect(struct mouse in)
{

	return (minx < in.start.x and in.start.x < maxx) and (miny < in.start.y and in.start.y < maxy);
	// this means that mouse will be moving and therefore moves into rect
}

bool on_edge(int index)
{
	struct mouse in = mice[index];

	return ((minx < in.start.x and in.start.x < maxx) and (in.start.y == miny or in.start.y == maxy)) or
	       ((miny < in.start.y and in.start.y < maxy) and (in.start.x == minx or in.start.x == maxx));
}

bool heading_in(int index)
{
	struct mouse in = mice[index];

	in.start.x += 0.00000000000000001 * in.x;
	in.start.y += 0.00000000000000001 * in.y;

	return inside_rect(in);
}

int main(void)
{
	//ifstream fin("__.in");
	//ofstream fout("__.out");
	cin >> n;
	cin >> minx >> miny >> maxx >> maxy;

	struct mouse in;

	double early = 0, late = 1000100;
	for(int i = 0; i < n; i++)
	{
		cin >> in.start.x >> in.start.y >> in.x >> in.y;
		mice.push_back(in);

		intersect(i);
		//cout << inside_rect(mice[i]) << endl;
		//cout << time1 << " " << time2 << endl << endl;
		if((time1 == -1 or time2 == -1) and not(inside_rect(mice[i])))
		{
			cout << -1 << endl;
			return 0;
		}

		if(not(inside_rect(mice[i])) and not(on_edge(i) and heading_in(i)))
			early = max(early, time1);
		if(time2 != -1)
			late = min(late, time2);
		else if(time2 == -1)
		{
			late = min(late, time1);
		}
		//cout << "late " << late << endl;
	}

	//cout << early << " " << late << endl;

	if(late <= early and late != -1)
	{
		cout << -1 << endl;
		return 0;
		//early = late;
	}

	cout << fixed << setprecision(20) << early << endl;
}


/*
ID: justinz3
PROG: __
LANG: C++
*/
#include <string>
#include <set>
#include <stdio.h>
#include <string.h>
#include <vector>
#include <iostream>
#include <algorithm>
#include <fstream>
#include <stdlib.h>
#include <math.h>
#include <iomanip>
#include <queue>
#include <map>
#include <typeinfo>
using namespace std;

#define PI 3.1415926535897932384626

struct point
{
	int x, y;
};

struct mouse
{
	struct point start;
	int x, y;
};

int n;
vector <struct mouse> mice;
int maxx, maxy, minx, miny; // rect

double time1, time2;
double one = 1;

void intersect(int index)
{
	struct mouse in = mice[index];

	time1 = -1;
	time2 = -1;

	//cout << time1 << " " << time2 << endl;

	if(in.y == 0 and (in.start.y == maxy or in.start.y == miny))
	{
		return;
	}
	if(in.x == 0 and (in.start.x == maxx or in.start.x == minx))
	{
		return;
	}

	double time;

	if(in.x != 0)
	{
		time = (one * minx - in.start.x) / in.x; // left side

		if(time >= 0 and miny <= in.start.y + in.y * time and in.start.y + in.y * time <= maxy)
		{
			//cout << "left " << time << endl;
			if(time1 >= 0 and time != time1)
				time2 = time;
			else
				time1 = time;
		}
		time = (one * maxx - in.start.x) / in.x; // right side

		if(time >= 0 and miny <= in.start.y + in.y * time and in.start.y + in.y * time <= maxy)
		{
			//cout << "right " << time << endl;
			if(time1 >= 0 and time != time1)
				time2 = time;
			else
				time1 = time;
		}
	}

	//cout << time1 << " " << time2 << endl;

	if(in.y != 0)
	{
		time = (one * miny - in.start.y) / in.y; // bottom

		if(time >= 0 and minx <= in.start.x + in.x * time and in.start.x + in.x * time <= maxx)
		{
			//cout << "bottom " << time << endl;
			if(time1 >= 0 and time != time1)
				time2 = time;
			else
				time1 = time;
		}

		time = (one * maxy - in.start.y) / in.y; // top

		if(time >= 0 and minx <= in.start.x + in.x * time and in.start.x + in.x * time <= maxx)
		{
			//cout << "top " << time << endl;
			if(time1 >= 0 and time != time1)
				time2 = time;
			else
				time1 = time;
		}
	}

	//cout << endl;
	double temp = time2;
	if(time1 > time2 and time2 != -1)
	{
		time2 = time1;
		time1 = temp;
	}
}

bool inside_rect(struct mouse in)
{

	return (minx < in.start.x and in.start.x < maxx) and (miny < in.start.y and in.start.y < maxy);
	// this means that mouse will be moving and therefore moves into rect
}

bool on_edge(int index)
{
	struct mouse in = mice[index];

	return ((minx < in.start.x and in.start.x < maxx) and (in.start.y == miny or in.start.y == maxy)) or
	       ((miny < in.start.y and in.start.y < maxy) and (in.start.x == minx or in.start.x == maxx));
}

bool heading_in(int index)
{
	struct mouse in = mice[index];

	in.start.x += 0.00000000000000001 * in.x;
	in.start.y += 0.00000000000000001 * in.y;

	return inside_rect(in);
}

int main(void)
{
	//ifstream fin("__.in");
	//ofstream fout("__.out");
	cin >> n;
	cin >> minx >> miny >> maxx >> maxy;

	struct mouse in;

	double early = 0, late = 1000100;
	for(int i = 0; i < n; i++)
	{
		cin >> in.start.x >> in.start.y >> in.x >> in.y;
		mice.push_back(in);

		intersect(i);
		//cout << inside_rect(i) << endl;
		//cout << time1 << " " << time2 << endl << endl;
		if(time1 == -1 or (time2 == -1 and not(inside_rect(mice[i]))))
		{
			cout << -1 << endl;
			return 0;
		}

		if(not(inside_rect(mice[i])) and not(on_edge(i) and heading_in(i)))
			early = max(early, time1);
		late = min(late, time2);
	}

	//cout << early << " " << late << endl;

	if(late < early and late != -1)
	{
		cout << -1 << endl;
		return 0;
		//early = late;
	}

	cout << fixed << setprecision(20) << early << endl;
}


//   Author:Arturia
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cctype>
#include<ctime>
#include<cstdlib>
#include<string>
#include<queue>
#include<cmath>
#include<set>
#include<map>
#include<bitset>
#include<vector>
#define rep(x,a,b) for (int x=a;x<=(int)(b);x++)
#define drp(x,a,b) for (int x=a;x>=(int)(b);x--)
#define cross(x,a) for (int x=hd[a];~x;x=nx[x])
#define ll long long
#define pii pair<int,int>
#define pdd pair<double,double>
#define mk(a,b) make_pair(a,b)
#define fs first
#define sc second
#define pb push_back
#define VI vector<int>
#define VS vector<string>
#define eps 1e-12
using namespace std;
inline ll rd(){
	ll x=0;int ch=getchar(),f=1;
	while (!isdigit(ch)&&(ch!='-')&&(ch!=EOF)) ch=getchar();
	if (ch=='-'){f=-1;ch=getchar();}
	while (isdigit(ch)){x=(x<<1)+(x<<3)+ch-'0';ch=getchar();}
	return x*f;
}
inline void rt(ll x){
	if (x<0) putchar('-'),x=-x;
	if (x>=10) rt(x/10),putchar(x%10+'0');
		else putchar(x+'0');
}
#define y1 fsdfasjkfjsdkla
#define y2 fksdjfaskdl
const int maxn=100005,inf=1000000000;
int n,x1,y1,x2,y2;
double l[maxn],r[maxn],nl,nr;
void noans(){
	puts("-1");
	exit(0);
}
int main(){
	n=rd();
	x1=rd(),y1=rd(),x2=rd(),y2=rd();
	rep(i,1,n) r[i]=inf;
	rep(i,1,n){
		int rx=rd(),ry=rd(),vx=rd(),vy=rd();
		if (vx){
			double nl=1.0*(x1-rx)/vx,nr=1.0*(x2-rx)/vx;
			if (nl>nr) swap(nl,nr);
			l[i]=max(l[i],nl),r[i]=min(r[i],nr);
		}
		else if (rx<=x1||rx>=x2) noans();
		if (vy){
			double nl=1.0*(y1-ry)/vy,nr=1.0*(y2-ry)/vy;
			if (nl>nr) swap(nl,nr);
			l[i]=max(l[i],nl),r[i]=min(r[i],nr);
		}
		else if (ry<=y1||ry>=y2) noans();
	}
	double mn=0;
	rep(i,1,n) mn=max(mn,l[i]);mn+=eps;
	rep(i,1,n) if (r[i]<mn) noans();
	printf("%.15lf\n",mn);
}


#include <ctime>
#include <cmath>
#include <cstdio>
#include <vector>
#include <cstring>
#include <cassert>
#include <iostream>
#include <algorithm>
#define fi first
#define se second
#define pb(x) push_back(x)
#define clr(x,y) memset(x,y,sizeof(x))
#define debug(x) cerr<<#x<<" = "<<x<<endl;
#define dig(...) fprintf(stderr,__VA_ARGS__)
#define rep(i,a,n) for(int i=a,i##_END_=n;i<i##_END_;++i)
#define per(i,a,n) for(int i=(n)-1,i##_BEGIN_=a;i>=i##_BEGIN_;--i)
#define showtime fprintf(stderr,"time = %.15f\n",clock()/(double)CLOCKS_PER_SEC)
using namespace std;
typedef double db;
typedef long double ldb;
typedef long long ll;
template<class Ty>inline void rd(Ty&res)
{
	res=0;char c;
	bool flag=false;
	while(c=getchar(),c!='-'&&(c<'0'||c>'9'));
	if(c=='-') flag=true,c=getchar();
	do res=res*10+(c^48);
	while(c=getchar(),c>='0'&&c<='9');
	if(flag) res=-res;
}
const int M=100000;
const ldb INF=1e200;
const ldb eps=1e-10;
int a1,a2,b1,b2,n,rx[M+5],ry[M+5],vx[M+5],vy[M+5];
ldb Mi[M+5],Mx[M+5];
int main()
{
	rd(n);
	rd(a1),rd(b1),rd(a2),rd(b2);
	rep(i,1,n+1) rd(rx[i]),rd(ry[i]),rd(vx[i]),rd(vy[i]);
	if(a1==a2||b1==b2)
	{
		puts("-1");
		return 0;
	}
	ldb x1=a1+eps,y1=b1+eps,x2=a2-eps,y2=b2-eps;
	rep(i,1,n+1)
	{
		ldb mi=-INF,mx=INF;
		ldb tmp1=INF,tmp2=INF,tmp3=INF,tmp4=INF;
		if(!vx[i]&&!vy[i])
		{
			if(rx[i]>=x1&&rx[i]<=x2&&ry[i]>=y1&&ry[i]<=y2)
			{
				mi=0;
				mx=INF;
			}
			else
			{
				puts("-1");
				return 0;
			}
		}
		if(vx[i])
		{
			tmp1=(x1-rx[i])/vx[i],tmp2=(x2-rx[i])/vx[i];
			if(vx[i]>0) tmp1=max(ldb(0),tmp1);
			else tmp2=max(ldb(0),tmp2);
			if(tmp1<=0&&tmp2<=0)
			{
				puts("-1");
				return 0;
			}
			mi=max(mi,min(tmp1,tmp2));
			mx=min(mx,max(tmp1,tmp2));
		}
		else if(rx[i]<x1||rx[i]>x2)
		{
			puts("-1");
			return 0;
		}
		if(vy[i])
		{
			tmp3=(y1-ry[i])/vy[i],tmp4=(y2-ry[i])/vy[i];
			if(vy[i]>0) tmp3=max(ldb(0),tmp3);
			else tmp4=max(ldb(0),tmp4);
			if(tmp3<=0&&tmp4<=0)
			{
				puts("-1");
				return 0;
			}
			mi=max(mi,min(tmp3,tmp4));
			mx=min(mx,max(tmp3,tmp4));
		}
		else if(ry[i]<y1||ry[i]>y2)
		{
			puts("-1");
			return 0;
		}
		Mi[i]=mi;
		Mx[i]=mx;
	}
	ldb mi=-INF,mx=INF;
	rep(i,1,n+1)
	{
		mi=max(mi,Mi[i]);
		mx=min(mx,Mx[i]);
	}
	if(mx<mi) puts("-1");
	else printf("%.10f\n",double(mi));
	return 0;
}


#define problem "793C"
/*
------------------------------------------------------
******************************************************
******************************************************
------------------------------------------------------
*/
#include <bits/stdc++.h>
#define fi first
#define se second
#define MEMSET_INF 127
#define Z 0
#define y1 sfsdjf
using namespace std;
typedef pair<int, int> ii;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef map<string, int> msi;
typedef map<int, vector<int> > mivi;
typedef pair<int, ii> i_ii;
typedef pair<ii, int> ii_i;
typedef pair<double, double> dd;
const ii queen[8] = {ii(-1, 0), ii(-1, 1), ii(0, 1), ii(1, 1), ii(1, 0), ii(1, -1), ii(0, -1), ii(-1, -1)};
const int maxN = 1e5 + 11;
typedef int i_N[maxN];
typedef double d_N[maxN];
int N;
int x1, y1, x2, y2;
i_N rx, ry, vx, vy;
d_N stx, enx, sty, eny, st, en;

ii operator + (const ii &a, const ii &b){
	return ii(a.fi + b.fi, a.se + b.se);
}

int main(){
    #ifndef ONLINE_JUDGE
	freopen(problem".INP", "r", stdin);
	freopen(problem".OUT", "w", stdout);
    #endif // ONLINE_JUDGE
    scanf("%d", &N);
    scanf("%d %d %d %d", &x1, &y1, &x2, &y2);
    for(int i = 1; i <= N; i++) scanf("%d %d %d %d", &rx[i], &ry[i], &vx[i], &vy[i]);
    fill(en + 1, en + N + 1, 1e18);
    double ST = Z, EN = 1e18;
    for(int i = 1; i <= N; i++){
        stx[i] = double(x1 - rx[i]) / vx[i];
        enx[i] = double(x2 - rx[i]) / vx[i];
        if(stx[i] > enx[i]) swap(stx[i], enx[i]);
        stx[i] = max((double)0, stx[i]);
        sty[i] = double(y1 - ry[i]) / vy[i];
        eny[i] = double(y2 - ry[i]) / vy[i];
        if(sty[i] > eny[i]) swap(sty[i], eny[i]);
        sty[i] = max(sty[i], (double)0);
        st[i] = max(stx[i], sty[i]);
        en[i] = min(enx[i], eny[i]);
        if(st[i] >= en[i]) return puts("-1") && Z;
        ST = max(ST, st[i]);
        EN = min(EN, en[i]);
    }
    if(ST >= EN) return puts("-1") && Z;
    printf("%.9lf\n", ST);
}


#define problem "793C"
/*
------------------------------------------------------
******************************************************
******************************************************
------------------------------------------------------
*/
#include <bits/stdc++.h>
#define fi first
#define se second
#define MEMSET_INF 127
#define Z 0
#define y1 sfsdjf
using namespace std;
typedef pair<int, int> ii;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef map<string, int> msi;
typedef map<int, vector<int> > mivi;
typedef pair<int, ii> i_ii;
typedef pair<ii, int> ii_i;
typedef pair<double, double> dd;
const ii queen[8] = {ii(-1, 0), ii(-1, 1), ii(0, 1), ii(1, 1), ii(1, 0), ii(1, -1), ii(0, -1), ii(-1, -1)};
const int maxN = 1e5 + 11;
typedef int i_N[maxN];
typedef double d_N[maxN];
int N;
int x1, y1, x2, y2;
i_N rx, ry, vx, vy;
d_N stx, enx, sty, eny, st, en;

ii operator + (const ii &a, const ii &b){
	return ii(a.fi + b.fi, a.se + b.se);
}

int main(){
    #ifndef ONLINE_JUDGE
	freopen(problem".INP", "r", stdin);
	freopen(problem".OUT", "w", stdout);
    #endif // ONLINE_JUDGE
    scanf("%d", &N);
    scanf("%d %d %d %d", &x1, &y1, &x2, &y2);
    for(int i = 1; i <= N; i++) scanf("%d %d %d %d", &rx[i], &ry[i], &vx[i], &vy[i]);
    fill(en + 1, en + N + 1, 1e18);
    double ST = Z, EN = 1e18;
    for(int i = 1; i <= N; i++){
        stx[i] = double(x1 - rx[i]) / vx[i];
        enx[i] = double(x2 - rx[i]) / vx[i];
        if(stx[i] > enx[i]) swap(stx[i], enx[i]);
        sty[i] = double(y1 - ry[i]) / vy[i];
        eny[i] = double(y2 - ry[i]) / vy[i];
        if(sty[i] > eny[i]) swap(sty[i], eny[i]);
        st[i] = max(stx[i], sty[i]);
        en[i] = min(enx[i], eny[i]);
        if(st[i] >= en[i]) return puts("-1") && Z;
        ST = max(ST, st[i]);
        EN = min(EN, en[i]);
    }
    if(ST >= EN) return puts("-1") && Z;
    printf("%.9lf\n", ST);
}


#define problem "793C"
/*
------------------------------------------------------
******************************************************
******************************************************
------------------------------------------------------
*/
#include <bits/stdc++.h>
#define fi first
#define se second
#define MEMSET_INF 127
#define Z 0
#define y1 sfsdjf
using namespace std;
typedef pair<int, int> ii;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef map<string, int> msi;
typedef map<int, vector<int> > mivi;
typedef pair<int, ii> i_ii;
typedef pair<ii, int> ii_i;
typedef pair<double, double> dd;
const ii queen[8] = {ii(-1, 0), ii(-1, 1), ii(0, 1), ii(1, 1), ii(1, 0), ii(1, -1), ii(0, -1), ii(-1, -1)};
const int maxN = 1e5 + 11;
typedef int i_N[maxN];
typedef double d_N[maxN];
int N;
int x1, y1, x2, y2;
i_N rx, ry, vx, vy;
d_N stx, enx, sty, eny, st, en;

ii operator + (const ii &a, const ii &b){
	return ii(a.fi + b.fi, a.se + b.se);
}

int main(){
    #ifndef ONLINE_JUDGE
	freopen(problem".INP", "r", stdin);
	freopen(problem".OUT", "w", stdout);
    #endif // ONLINE_JUDGE
    scanf("%d", &N);
    scanf("%d %d %d %d", &x1, &y1, &x2, &y2);
    for(int i = 1; i <= N; i++) scanf("%d %d %d %d", &rx[i], &ry[i], &vx[i], &vy[i]);
    fill(en + 1, en + N + 1, 1e18);
    double ST = Z, EN = 1e18;
    for(int i = 1; i <= N; i++){
        stx[i] = double(x1 - rx[i]) / vx[i] + 1e-7;
        enx[i] = double(x2 - rx[i]) / vx[i] - 1e-7;
        if(stx[i] > enx[i]) swap(stx[i], enx[i]);
        sty[i] = double(y1 - ry[i]) / vy[i] + 1e-7;
        eny[i] = double(y2 - ry[i]) / vy[i] - 1e-7;
        if(sty[i] > eny[i]) swap(sty[i], eny[i]);
        st[i] = max(stx[i], sty[i]);
        en[i] = min(enx[i], eny[i]);
        if(st[i] > en[i]) return puts("-1") && Z;
        ST = max(ST, st[i]);
        EN = min(EN, en[i]);
    }
    if(ST > EN) return puts("-1") && Z;
    printf("%.9lf\n", ST);
}


#define problem "793C"
/*
------------------------------------------------------
******************************************************
******************************************************
------------------------------------------------------
*/
#include <bits/stdc++.h>
#define fi first
#define se second
#define MEMSET_INF 127
#define Z 0
#define y1 sfsdjf
using namespace std;
typedef pair<int, int> ii;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef map<string, int> msi;
typedef map<int, vector<int> > mivi;
typedef pair<int, ii> i_ii;
typedef pair<ii, int> ii_i;
typedef pair<double, double> dd;
const ii queen[8] = {ii(-1, 0), ii(-1, 1), ii(0, 1), ii(1, 1), ii(1, 0), ii(1, -1), ii(0, -1), ii(-1, -1)};
const int maxN = 1e5 + 11;
typedef int i_N[maxN];
typedef double d_N[maxN];
int N;
int x1, y1, x2, y2;
i_N rx, ry, vx, vy;
d_N stx, enx, sty, eny, st, en;

ii operator + (const ii &a, const ii &b){
	return ii(a.fi + b.fi, a.se + b.se);
}

int main(){
    #ifndef ONLINE_JUDGE
	freopen(problem".INP", "r", stdin);
	freopen(problem".OUT", "w", stdout);
    #endif // ONLINE_JUDGE
    scanf("%d", &N);
    scanf("%d %d %d %d", &x1, &y1, &x2, &y2);
    for(int i = 1; i <= N; i++) scanf("%d %d %d %d", &rx[i], &ry[i], &vx[i], &vy[i]);
    fill(en + 1, en + N + 1, 1e18);
    double ST = Z, EN = 1e18;
    for(int i = 1; i <= N; i++){
        stx[i] = double(x1 - rx[i]) / vx[i];
        enx[i] = double(x2 - rx[i]) / vx[i];
        if(stx[i] > enx[i]) swap(stx[i], enx[i]);
        stx[i] += 1e-7;
        enx[i] -= 1e-7;
        sty[i] = double(y1 - ry[i]) / vy[i];
        eny[i] = double(y2 - ry[i]) / vy[i];
        if(sty[i] > eny[i]) swap(sty[i], eny[i]);
        sty[i] += 1e-7;
        eny[i] -= 1e-7;
        st[i] = max(stx[i], sty[i]);
        en[i] = min(enx[i], eny[i]);
        if(st[i] > en[i]) return puts("-1") && Z;
        ST = max(ST, st[i]);
        EN = min(EN, en[i]);
    }
    if(ST > EN) return puts("-1") && Z;
    printf("%.9lf\n", ST);
}


#include <bits/stdc++.h>

#define all(A) begin(A), end(A)
#define rall(A) rbegin(A), rend(A)
#define sz(A) int(A.size())
#define pb push_back
#define mp make_pair

using namespace std;

typedef long long ll;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef vector <int> vi;
typedef vector <ll> vll;
typedef vector <pii> vpii;
typedef vector <pll> vpll;

int main () {
  ios::sync_with_stdio(false); cin.tie(0);
  int m;
  cin >> m;
  string s;
  cin >> s;
  vector <deque <int>> arr(26);
  for (int i = 0; i < m; i++) {
    arr[s[i] - 'a'].pb(i);
  }
  vi ans_i;
  char ch_mx = 'a';
  auto add = [&] () {
    for (auto& row: arr) {
      if (row.empty()) continue;
      ans_i.pb(row.front());
      ch_mx = max(ch_mx, s[row.front()]);
      return;
    }
    return;
  };
  add();
  for (int i = m; i < sz(s); i++) {
    arr[s[i - m] - 'a'].pop_front();
    arr[s[i] - 'a'].pb(i);
    add();
  }
  for (int i = 0; i < sz(s); i++) {
    if (s[i] < ch_mx) ans_i.pb(i);
  }
  sort(all(ans_i));
  ans_i.erase(unique(all(ans_i)), end(ans_i));
  string ans_s = "";
  for (int i: ans_i) ans_s += s[i];
  sort(all(ans_s));
  cout << ans_s << '\n';
  return (0);
}


#include <bits/stdc++.h>

#define all(A) begin(A), end(A)
#define rall(A) rbegin(A), rend(A)
#define sz(A) int(A.size())
#define pb push_back
#define mp make_pair

using namespace std;

typedef long long ll;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef vector <int> vi;
typedef vector <ll> vll;
typedef vector <pii> vpii;
typedef vector <pll> vpll;

int main () {
  ios::sync_with_stdio(false); cin.tie(0);
  int m;
  cin >> m;
  string s;
  cin >> s;
  vector <deque <int>> arr(26);
  for (int i = 0; i < m; i++) {
    arr[s[i] - 'a'].pb(i);
  }
  vi ans_i;
  char ch_mx = 'a';
  auto add = [&] () {
    for (auto& row: arr) {
      if (row.empty()) continue;
      ans_i.pb(row.front());
      ch_mx = max(ch_mx, s[row.front()]);
      return;
    }
    return;
  };
  add();
  for (int i = m; i < sz(s); i++) {
    arr[s[i - m] - 'a'].pop_front();
    arr[s[i] - 'a'].pb(i);
    add();
  }
  for (int i = 0; i < sz(s); i++) {
    if (s[i] < ch_mx) ans_i.pb(i);
  }
  sort(all(ans_i));
  ans_i.erase(unique(all(ans_i)), end(ans_i));
  string ans_s = "";
  for (int i = 0; i < sz(ans_i); i++) {
    if (s[ans_i[i]] != ch_mx) {
      ans_s += s[ans_i[i]];
    } else {
      int p = (0 <= i - 1) ? ans_i[i - 1] : -1;
      int n = (i + 1 < sz(ans_i)) ? ans_i[i + 1] : sz(s);
      if (n - p <= m) continue;
      ans_s += s[ans_i[i]];
    }
  }
  sort(all(ans_s));
  cout << ans_s << '\n';
  return (0);
}


// I feel so stupid xd

#include <bits/stdc++.h>

#define all(A) begin(A), end(A)
#define rall(A) rbegin(A), rend(A)
#define sz(A) int(A.size())
#define pb push_back
#define mp make_pair

using namespace std;

typedef long long ll;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef vector <int> vi;
typedef vector <ll> vll;
typedef vector <pii> vpii;
typedef vector <pll> vpll;

int main () {
  ios::sync_with_stdio(false); cin.tie(0);
  int m;
  cin >> m;
  string s;
  cin >> s;
  auto get = [&] (char ch) {
    int need = 0;
    int last = -1;
    int choice = -1;
    for (int i = 0; i < sz(s); i++) {
      if (s[i] < ch) last = choice = i;
      if (s[i] == ch) choice = i;
      if (i - last == m) {
        if (last >= choice) {
          return -1;
        }
        need++;
        last = choice;
      }
    }
    return need;
  };
  for (char ch = 'a'; ch <= 'z'; ch++) {
    int need = get(ch);
    if (need == -1) continue;
    for (char c = 'a'; c < ch; c++) {
      for (int i = 0; i < sz(s); i++) {
        if (s[i] == c) cout << s[i];
      }
    }
    for (int i = 0; i < need; i++) cout << ch;
    cout << '\n';
    break;
  }
  return (0);
}


// aa > a ?

#include <bits/stdc++.h>

#define all(A) begin(A), end(A)
#define rall(A) rbegin(A), rend(A)
#define sz(A) int(A.size())
#define pb push_back
#define mp make_pair

using namespace std;

typedef long long ll;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef vector <int> vi;
typedef vector <ll> vll;
typedef vector <pii> vpii;
typedef vector <pll> vpll;

int main () {
  ios::sync_with_stdio(false); cin.tie(0);
  int m;
  cin >> m;
  string s;
  cin >> s;
  vector <deque <int>> arr(26);
  for (int i = 0; i < m; i++) {
    arr[s[i] - 'a'].pb(i);
  }
  vi ans_i;
  char ch_mx = 'a';
  auto add = [&] () {
    for (auto& row: arr) {
      if (row.empty()) continue;
      ans_i.pb(row.back());
      ch_mx = max(ch_mx, s[row.back()]);
      return;
    }
    return;
  };
  add();
  for (int i = m; i < sz(s); i++) {
    arr[s[i - m] - 'a'].pop_front();
    arr[s[i] - 'a'].pb(i);
    add();
  }
  for (int i = 0; i < sz(s); i++) {
    if (s[i] < ch_mx or ch_mx == 'a') ans_i.pb(i);
  }
  sort(all(ans_i));
  ans_i.erase(unique(all(ans_i)), end(ans_i));
  string ans_s = "";
  for (int i = 0; i < sz(ans_i); i++) {
    if (s[ans_i[i]] != ch_mx) {
      ans_s += s[ans_i[i]];
    } else {
      int p = (0 <= i - 1) ? ans_i[i - 1] : -1;
      int n = (i + 1 < sz(ans_i)) ? ans_i[i + 1] : sz(s);
      if (n - p <= m) continue;
      ans_s += s[ans_i[i]];
    }
  }
  sort(all(ans_s));
  cout << ans_s << '\n';
  return (0);
}


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

int n, m, bot = 0, fre[26], fin[100001];
string s;
char last;

void body() {
    cin >> m >> s;

    n = s.length();
    for (int i = 0; i < n; ++i) {
        ++fre[s[i] - 'a'];
    }

    for (char c = 'a'; c <= 'z'; ++c) {
        int curLen = 0;
        bool okay = 1;

        for (int i = 0; i < n; ++i) {
            if (s[i] > c) {
                ++curLen;
                if (curLen >= m) {
                    okay = 0;
                    break;
                }
            } else {
                curLen = 0;
            }
        }

        if (okay) {
            last = c;
            break;
        }
    }

    if (fre[last - 'a'] == n) {
        for (int i = 0; i < n; ++i) {
            if (s[i] == last) {
                cout << last;
                if (i >= n - m) {
                    break;
                }
            }
        }
        return;
    }

    for (int i = n - 1; i >= 0; --i) {
        if (s[i] < last) {
            bot = i;
            break;
        }
    }

    for (int i = 0; i < n; ++i) {
        if (i > 0)
            fin[i] = fin[i - 1];

        if (s[i] == last)
            fin[i] = i;
    }

    int curLen = 0, F = 0;

    for (int i = 0; i < n; ++i) {
        if (s[i] >= last) {
            ++curLen;
            if (curLen >= m) {
                curLen = fin[i] + m - 1 - i;
                ++F;
            }
        } else {
            curLen = 0;
        }
    }

    fre[last - 'a'] = F;
    for (int i = 0; i <= last - 'a'; ++i) {
        for (int j = 0; j < fre[i]; ++j) {
            cout << char(i + 'a');
        }
    }

}

int main() {
//    freopen("main.in","r",stdin);
    ios::sync_with_stdio(0);
    body();
    fclose(stdin);
}


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

int n, m, bot = 0, fre[26], fin[100001];
string s;
char last, mini = 'z';

void body() {
    cin >> m >> s;

    n = s.length();
    for (int i = 0; i < n; ++i) {
        ++fre[s[i] - 'a'];
        mini = min(mini, s[i]);
    }

    for (char c = 'a'; c <= 'z'; ++c) {
        int curLen = 0;
        bool okay = 1;

        for (int i = 0; i < n; ++i) {
            if (s[i] > c) {
                ++curLen;
                if (curLen >= m) {
                    okay = 0;
                    break;
                }
            } else {
                curLen = 0;
            }
        }

        if (okay) {
            last = c;
            break;
        }
    }

    for (int i = 0; i < n; ++i) {
        if (i > 0)
            fin[i] = fin[i - 1];

        if (s[i] == last)
            fin[i] = i;
    }

    int curLen = 0, F = 0;

    for (int i = 0; i < n; ++i) {
        if (s[i] >= last) {
            ++curLen;
            if (curLen >= m) {
                curLen = -(fin[i] + m - 1 - i);
                ++F;
            }
        } else {
            curLen = 0;
        }
    }

    fre[last - 'a'] = F;
    for (int i = 0; i <= last - 'a'; ++i) {
        for (int j = 0; j < fre[i]; ++j) {
            cout << char(i + 'a');
        }
    }

}

int main() {
    //freopen("main.in","r",stdin);
    ios::sync_with_stdio(0);
    body();
    fclose(stdin);
}


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

int n, m, fre[26], fin[100001];
string s;
char last;

void body() {
    cin >> m >> s;

    n = s.length();
    for (int i = 0; i < n; ++i) {
        ++fre[s[i] - 'a'];
    }

    for (char c = 'a'; c <= 'z'; ++c) {
        if (fre[c - 'a'] == 0) {
            continue;
        }

        int curLen = 0;
        bool okay = 1;

        for (int i = 0; i < n; ++i) {
            if (s[i] > c) {
                ++curLen;

                if (curLen >= m) {
                    okay = 0;
                    break;
                }
            } else {
                curLen = 0;
            }
        }

        if (okay) {
            last = c;
            break;
        }
    }

    for (int i = 0; i < n; ++i) {
        if (i > 0)
            fin[i] = fin[i - 1];

        if (s[i] == last)
            fin[i] = i;
    }

    int curLen = 0, F = 0;

    for (int i = 0; i < n; ++i) {
        if (s[i] >= last) {
            ++curLen;
            if (curLen >= m) {
                curLen = i - fin[i];
                ++F;
            }
        } else {
            curLen = 0;
        }
    }

    fre[last - 'a'] = F;
    for (int i = 0; i <= last - 'a'; ++i) {
        for (int j = 0; j < fre[i]; ++j) {
            cout << char(i + 'a');
        }
    }

}
/*
 if (last == mini) {
        for (int i = 0; i < n; ++i) {
            if (s[i] == last) {
                cout << last;
                if (i >= n - m) {
                    break;
                }
            }
        }
        return;
    }
 */
int main() {
    //freopen("main.in","r",stdin);
    ios::sync_with_stdio(0);
    body();
    fclose(stdin);
}


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

int n, m, bot = 0, fre[26], fin[100001];
string s;
char last, mini = 'z';

void body() {
    cin >> m >> s;

    n = s.length();
    for (int i = 0; i < n; ++i) {
        ++fre[s[i] - 'a'];
        mini = min(mini, s[i]);
    }

    for (char c = 'a'; c <= 'z'; ++c) {
        int curLen = 0;
        bool okay = 1;

        for (int i = 0; i < n; ++i) {
            if (s[i] > c) {
                ++curLen;
                if (curLen >= m) {
                    okay = 0;
                    break;
                }
            } else {
                curLen = 0;
            }
        }

        if (okay) {
            last = c;
            break;
        }
    }

    if (last == mini) {
        for (int i = 0; i < n; ++i) {
            if (s[i] == last) {
                cout << last;
                if (i >= n - m) {
                    break;
                }
            }
        }
        return;
    }

    for (int i = 0; i < n; ++i) {
        if (i > 0)
            fin[i] = fin[i - 1];

        if (s[i] == last)
            fin[i] = i;
    }

    int curLen = 0, F = 0;

    for (int i = 0; i < n; ++i) {
        if (s[i] >= last) {
            ++curLen;
            if (curLen >= m) {
                curLen = -(fin[i] + m - 1 - i);
                ++F;
            }
        } else {
            curLen = 0;
        }
    }

    fre[last - 'a'] = F;
    for (int i = 0; i <= last - 'a'; ++i) {
        for (int j = 0; j < fre[i]; ++j) {
            cout << char(i + 'a');
        }
    }

}

int main() {
    //freopen("main.in","r",stdin);
    ios::sync_with_stdio(0);
    body();
    fclose(stdin);
}


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

int n, m, bot = 0, fre[26], fin[100001];
string s;
char last;

void body() {
    cin >> m >> s;

    n = s.length();
    for (int i = 0; i < n; ++i) {
        ++fre[s[i] - 'a'];
    }

    for (char c = 'a'; c <= 'z'; ++c) {
        int curLen = 0;
        bool okay = 1;

        for (int i = 0; i < n; ++i) {
            if (s[i] > c) {
                ++curLen;
                if (curLen >= m) {
                    okay = 0;
                    break;
                }
            } else {
                curLen = 0;
            }
        }

        if (okay) {
            last = c;
            break;
        }
    }

    if (fre[last - 'a'] == n) {
        for (int i = 0; i < n; ++i) {
            if (s[i] == last) {
                cout << last;
                if (i >= n - m) {
                    break;
                }
            }
        }
        return;
    }

    for (int i = 0; i < n; ++i) {
        if (i > 0)
            fin[i] = fin[i - 1];

        if (s[i] == last)
            fin[i] = i;
    }

    int curLen = 0, F = 0;

    for (int i = 0; i < n; ++i) {
        if (s[i] >= last) {
            ++curLen;
            if (curLen >= m) {
                curLen = -(fin[i] + m - 1 - i);
                ++F;
            }
        } else {
            curLen = 0;
        }
    }

    fre[last - 'a'] = F;
    for (int i = 0; i <= last - 'a'; ++i) {
        for (int j = 0; j < fre[i]; ++j) {
            cout << char(i + 'a');
        }
    }

}

int main() {
    //freopen("main.in","r",stdin);
    ios::sync_with_stdio(0);
    body();
    fclose(stdin);
}


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

int n, m, bot = 0, fre[26], fin[100001];
string s;
char last;

void body() {
    cin >> m >> s;

    n = s.length();
    for (char c = 'a'; c <= 'z'; ++c) {
        int curLen = 0;
        bool okay = 1;

        for (int i = 0; i < n; ++i) {
            if (s[i] > c) {
                ++curLen;
                if (curLen >= m) {
                    okay = 0;
                    break;
                }
            } else {
                curLen = 0;
            }
        }

        if (okay) {
            last = c;
            break;
        }
    }

    if (last == 'a') {
        for (int i = 0; i < n; ++i) {
            if (s[i] == 'a') {
                cout << 'a';
                if (i >= n - m) {
                    break;
                }
            }
        }
        return;
    }

    for (int i = n - 1; i >= 0; --i) {
        if (s[i] < last) {
            bot = i;
            break;
        }
    }

    for (int i = 0; i < n; ++i) {
        if (i > 0)
            fin[i] = fin[i - 1];

        if (s[i] == last)
            fin[i] = i;
    }

    int curLen = 0, F = 0;
    char c = last;

    for (int i = 0; i < n; ++i) {
        ++fre[s[i] - 'a'];
        if (s[i] >= c) {
            ++curLen;
            if (curLen == m) {
                curLen = m - (i - fin[i] + 1);
                ++F;
            }
        } else {
            curLen = 0;
        }
    }

    fre[last - 'a'] = F;
    for (int i = 0; i <= last - 'a'; ++i) {
        for (int j = 0; j < fre[i]; ++j) {
            cout << char(i + 'a');
        }
    }

}

int main() {
//    freopen("main.in","r",stdin);
    ios::sync_with_stdio(0);
    body();
    fclose(stdin);
}


/*input
2
abcab
*/
#include <iostream>
#include <cstdio>
#include <vector>
#include <functional>
#include <math.h>
#include <string.h>
#include <utility>
#include <algorithm>
#include <iomanip>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <stdlib.h>
#include <list>
#include <assert.h>
#include <time.h>
#include <fstream>
#include <sstream>
using namespace std;
#define sp ' '
#define endl '\n'
#define fi first
#define se second
#define mp make_pair
#define ll long long
#define N 100005
#define INF 2139062143

deque<pair<char, int> > dq;
int m;
string s;
int nearest = -1;
bool done[N];
int main() {
	ios_base::sync_with_stdio(false); cin.tie(0);
	cin >> m;
	cin >> s;
	for (int i = 0; i < m - 1; i++) {
		while (!dq.empty() && dq.back().fi > s[i]) dq.pop_back();
		dq.push_back(mp(s[i], i));
	}
	string ans;
	for (char c = 'a'; c <= 'z'; c++) {
		nearest = -1;
		dq.clear();
		for (int i = 0; i < m - 1; i++) {
			if (done[i]) nearest = i;
			if (s[i] == c) {
				dq.clear();
				dq.push_back(mp(s[i], i));
			}
		}
		for (int i = m - 1; i < s.size(); i++) {
			while (!dq.empty() && dq.front().se < i - m + 1) dq.pop_front();
			if (s[i] == c) {
				dq.clear();
				dq.push_back(mp(s[i], i));
			}
			if (done[i]) nearest = i;
			if (i - nearest >= m && !dq.empty()) {
				done[dq.front().se] = true;
				nearest = dq.front().se;
				ans += dq.front().fi;
				nearest = dq.front().se;
			}
		}
	}
	// for (int i = 0; i < s.size(); i++) cout << done[i] << sp;
	sort(ans.begin(), ans.end());
	cout << ans << endl;
}


/*input
3
cbabc
*/
#include <iostream>
#include <cstdio>
#include <vector>
#include <functional>
#include <math.h>
#include <string.h>
#include <utility>
#include <algorithm>
#include <iomanip>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <stdlib.h>
#include <list>
#include <assert.h>
#include <time.h>
#include <fstream>
#include <sstream>
using namespace std;
#define sp ' '
#define endl '\n'
#define fi first
#define se second
#define mp make_pair
#define ll long long
#define N 100005
#define INF 2139062143

deque<pair<char, int> > dq;
int m;
string s;
int nearest = -1;
bool done[N];

bool ok(char c) {
	nearest = -1;
	for (int i = 0; i < s.size(); i++) {
		if (s[i] == c) nearest = i;
		if (done[i]) nearest = i;
		if (i - nearest >= m) return false;
	}
	return true;
}

int main() {
	ios_base::sync_with_stdio(false); cin.tie(0);
	cin >> m;
	cin >> s;
	string ans;
	for (char c = 'a'; c <= 'z'; c++) {
		nearest = -1;
		dq.clear();
		for (int i = 0; i < s.size(); i++) if (s[i] == c) done[i] = true;
		if (ok(c)) {
			nearest = -1;
			for (int i = 0; i < s.size(); i++) if (s[i] == c) done[i] = false;
			for (int i = 0; i < m - 1; i++) {
				if (s[i] == c) dq.clear(), dq.push_back(mp(s[i], i));
			}
			for (int i = m - 1; i < s.size(); i++) {
				while (!dq.empty() && dq.front().se < i - m + 1) dq.pop_front();
				if (done[i]) nearest = i;
				if (s[i] == c) {
					done[i] = true;
					dq.clear();
					dq.push_back(mp(s[i], i));
				}
				if (i - nearest >= m && !dq.empty()) {
					done[dq.front().se] = true;
					nearest = dq.front().se;
					ans += dq.front().fi;
					nearest = dq.front().se;
					dq.pop_front();
				}
			}
			break;
		}
		else {
			for (int i = 0; i < s.size(); i++) if (s[i] == c) ans += c;
		}
	}
	sort(ans.begin(), ans.end());
	cout << ans << endl;
}


/*input
3
cbabc
*/
#include <iostream>
#include <cstdio>
#include <vector>
#include <functional>
#include <math.h>
#include <string.h>
#include <utility>
#include <algorithm>
#include <iomanip>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <stdlib.h>
#include <list>
#include <assert.h>
#include <time.h>
#include <fstream>
#include <sstream>
using namespace std;
#define sp ' '
#define endl '\n'
#define fi first
#define se second
#define mp make_pair
#define ll long long
#define N 100005
#define INF 2139062143

deque<pair<char, int> > dq;
int m;
string s;
int nearest = -1;
bool done[N];

bool ok(char c) {
	nearest = -1;
	for (int i = 0; i < s.size(); i++) {
		if (s[i] == c) nearest = i;
		if (done[i]) nearest = i;
		if (i - nearest >= m) return false;
	}
	return true;
}

int main() {
	ios_base::sync_with_stdio(false); cin.tie(0);
	cin >> m;
	cin >> s;
	string ans;
	for (char c = 'a'; c <= 'z'; c++) {
		nearest = -1;
		dq.clear();
		for (int i = 0; i < s.size(); i++) if (s[i] == c) done[i] = true;
		if (ok(c)) {
			nearest = -1;
			for (int i = 0; i < s.size(); i++) if (s[i] == c) done[i] = false;
			for (int i = 0; i < m - 1; i++) {
				if (done[i]) nearest = i;
				if (s[i] == c) dq.clear(), dq.push_back(mp(s[i], i));
			}
			for (int i = m - 1; i < s.size(); i++) {
				while (!dq.empty() && dq.front().se < i - m + 1) dq.pop_front();
				if (done[i]) nearest = i;
				if (s[i] == c) {
					done[i] = true;
					dq.clear();
					dq.push_back(mp(s[i], i));
				}
				if (i - nearest >= m && !dq.empty()) {
					done[dq.front().se] = true;
					nearest = dq.front().se;
					ans += dq.front().fi;
					dq.pop_front();
				}
			}
			break;
		}
		else {
			for (int i = 0; i < s.size(); i++) if (s[i] == c) ans += c;
		}
	}
	sort(ans.begin(), ans.end());
	cout << ans << endl;
}


/*input
4
cbccbacbab
*/
#include <iostream>
#include <cstdio>
#include <vector>
#include <functional>
#include <math.h>
#include <string.h>
#include <utility>
#include <algorithm>
#include <iomanip>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <stdlib.h>
#include <list>
#include <assert.h>
#include <time.h>
#include <fstream>
#include <sstream>
using namespace std;
#define sp ' '
#define endl '\n'
#define fi first
#define se second
#define mp make_pair
#define ll long long
#define N 100005
#define INF 2139062143

deque<pair<char, int> > dq;
int m;
string s;
int nearest = -1;
bool done[N];
int main() {
	ios_base::sync_with_stdio(false); cin.tie(0);
	cin >> m;
	cin >> s;
	string ans;
	for (char c = 'a'; c <= 'z'; c++) {
		nearest = -1;
		dq.clear();
		for (int i = 0; i < m - 1; i++) {
			if (done[i]) nearest = i;
			if (s[i] == c) {
				dq.clear();
				dq.push_back(mp(s[i], i));
			}
		}
		for (int i = m - 1; i < s.size(); i++) {
			while (!dq.empty() && dq.front().se < i - m + 1) dq.pop_front();
			if (done[i]) nearest = i;
			if (s[i] == c) {
				dq.clear();
				dq.push_back(mp(s[i], i));
			}
			if (i - nearest >= m && !dq.empty()) {
				done[dq.front().se] = true;
				nearest = dq.front().se;
				ans += dq.front().fi;
				nearest = dq.front().se;
				dq.pop_front();
			}
		}
	}
	// for (int i = 0; i < s.size(); i++) cout << done[i] << sp;
	sort(ans.begin(), ans.end());
	cout << ans << endl;
}


/*input
3
bbaabb
*/
#include <iostream>
#include <cstdio>
#include <vector>
#include <functional>
#include <math.h>
#include <string.h>
#include <utility>
#include <algorithm>
#include <iomanip>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <stdlib.h>
#include <list>
#include <assert.h>
#include <time.h>
#include <fstream>
#include <sstream>
using namespace std;
#define sp ' '
#define endl '\n'
#define fi first
#define se second
#define mp make_pair
#define ll long long
#define N 100005
#define INF 2139062143

deque<pair<char, int> > dq;
int m;
string s;
int nearest = -1;
bool done[N];

bool ok() {
	nearest = -1;
	for (int i = 0; i < s.size(); i++) {
		if (done[i]) nearest = i;
		if (i - nearest >= m) return false;
	}
	return true;
}

int main() {
	ios_base::sync_with_stdio(false); cin.tie(0);
	cin >> m;
	cin >> s;
	string ans;
	for (char c = 'a'; c <= 'z'; c++) {
		nearest = -1;
		dq.clear();
		for (int i = 0; i < s.size(); i++) if (s[i] == c) done[i] = true;
		if (ok()) {
			nearest = -1;
			for (int i = 0; i < s.size(); i++) if (s[i] == c) done[i] = false;
			for (int i = m - 1; i < s.size(); i++) {
				while (!dq.empty() && dq.front().se < i - m + 1) dq.pop_front();
				if (done[i]) nearest = i;
				if (s[i] == c) {
					done[i] = true;
					dq.clear();
					dq.push_back(mp(s[i], i));
				}
				if (i - nearest >= m && !dq.empty()) {
					done[dq.front().se] = true;
					nearest = dq.front().se;
					ans += c;
					dq.pop_front();
				}
			}
			break;
		}
		else {
			for (int i = 0; i < s.size(); i++) if (s[i] == c) ans += c;
		}
	}
	sort(ans.begin(), ans.end());
	cout << ans << endl;
}


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

const int NX = 123456;
const int ALPHAX = 'z' + 2;
char a[NX];
int N;
int SIZE;
int nearest[ALPHAX][NX];
set <char> s[ALPHAX];
struct BinaryIndexedTree {
  int data[NX];
  BinaryIndexedTree () { memset(data, 0, sizeof(data)); }
  void up (int pos, int v) {
    for (int node = pos; node <= N; node += node & -node) {
      data[node] += v;
    }
  }
  int get (int pos) {
    int res = 0;
    for (int node = pos; node > 0; node -= node & -node) {
      res += data[node];
    }
    return res;
  }
  int get (int LL, int RR) {
    return get(RR) - get(LL - 1);
  }
} BIT;

int main() {
  #define file "in"
  //freopen(file".inp","r",stdin); freopen(file".out","w", stdout);
  scanf("%d %s", &SIZE, a + 1);
  N = strlen(a + 1);
  for (int i = 1; i <= N; i++) {
    for (char c = 'a'; c <= 'z'; c++) {
      if (a[i] == c) nearest[c][i] = i;
      else nearest[c][i] = nearest[c][i - 1];
    }
    s[a[i]].insert(i);
  }
  string res;
  for (char c = 'a'; c <= 'z'; c++) {
    //for (int where : s[c]) cout << where << " "; cout << endl;
    int finished = true;
    for (int i = 1; i <= N - SIZE + 1; i++) {
      int where = nearest[c][i + SIZE - 1];
      if (BIT.get(i, i + SIZE - 1) == 0 && where >= i && s[c].count(where)) {
        s[c].erase (where);
        BIT.up(where, 1);
        res += c;
      } else if (BIT.get(i, i + SIZE - 1) == 0) {
        finished = false;
      }
    }
    if (finished) break;
    for (int where : s[c]) {
      BIT.up(where, 1);
      res += c;
    }
    s[c].clear();
  }
  cout << res;
}


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

const int NX = 123456;
const int ALPHAX = 'z' + 2;
char a[NX];
int N;
int SIZE;
int nearest[ALPHAX][NX];
set <char> s[ALPHAX];
struct BinaryIndexedTree {
  int data[NX];
  BinaryIndexedTree () { memset(data, 0, sizeof(data)); }
  void up (int pos, int v) {
    for (int node = pos; node <= N; node += node & -node) {
      data[node] += v;
    }
  }
  int get (int pos) {
    int res = 0;
    for (int node = pos; node > 0; node -= node & -node) {
      res += data[node];
    }
    return res;
  }
  int get (int LL, int RR) {
    return get(RR) - get(LL - 1);
  }
} BIT;

int main() {
  #define file "in"
  //freopen(file".inp","r",stdin); freopen(file".out","w", stdout);
  scanf("%d %s", &SIZE, a + 1);
  N = strlen(a + 1);
  for (int i = 1; i <= N; i++) {
    for (char c = 'a'; c <= 'z'; c++) {
      if (a[i] == c) nearest[c][i] = i;
      else nearest[c][i] = nearest[c][i - 1];
    }
    s[a[i]].insert(i);
  }
  string res;
  for (char c = 'a'; c <= 'z'; c++) {
    //for (int where : s[c]) cout << where << " "; cout << endl;
    int finished = true;
    for (int i = 1; i <= N - SIZE + 1; i++) {
      int where = nearest[c][i + SIZE - 1];
      if (BIT.get(i, i + SIZE - 1) == 0 && where >= i && s[c].count(where)) {
        s[c].erase (where);
        BIT.up(where, 1);
        res += c;
      } else if (BIT.get(i, i + SIZE - 1) == 0) {
        finished = false;
      }
    }
    if (finished) break;
    for (int times = 1; times <= s[c].size(); times++) {
      res += c;
    }
    s[c].clear();
  }
  cout << res;
}


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

#define MM ((LL + RR) / 2)
#define LEFTT (node * 2)
#define RIGHT (node * 2 + 1)

const int NX = 1e5 + 10;
const int oo = 1e9 + 7;
vector <char> v;
int N, SIZE;
char a[NX];
int used[NX];
struct segment {
  int whereMin, min;
  segment() {}
  segment(int min, int whereMin) : min(min), whereMin(whereMin) {}
} IT[4 * NX];
segment merge (segment a, segment b) {
  segment res;
  res.whereMin = a.whereMin * (a.min <= b.min) + b.whereMin * (a.min > b.min);
  res.min = min(a.min, b.min);
  return res;
}
void build (int node = 1, int LL = 1, int RR = N) {
  if (LL == RR) {
    IT[node] = segment(a[LL], LL);
  } else {
    build (LEFTT, LL, MM);
    build (RIGHT, MM + 1, RR);
    IT[node] = merge(IT[node * 2], IT[node * 2 + 1]);
  }
}

segment get (int x, int y, int node = 1, int LL = 1, int RR = N) {
  if (x > RR || y < LL) return segment (oo, 0);
  if (x <= LL && RR <= y) {
    return IT[node];
  } else {
    return merge (get(x, y, LEFTT, LL, MM),
                  get(x, y, RIGHT, MM + 1, RR));
  }
}

int main() {
  #define file "in"
  //freopen(file".inp","r",stdin); freopen(file".out","w", stdout);
  scanf("%d", &SIZE);
  scanf("%s", a + 1);
  N = strlen(a + 1);
  build();
  for (int i = 1; i <= N - SIZE + 1; i++) {
    segment res = get (i, i + SIZE - 1);
    if (used[res.whereMin]) continue;
    used[res.whereMin] = 1;
    v.push_back(res.min);
  }
  sort (v.begin(), v.end());
  int maxChar = v.back();
  /*
  printf("%d\n", v.size());
  for (int i = 0; i < v.size(); i++) {
    printf("%c", char(v[i]));
  }
  printf("\n");
  */
  for (int i = 1; i <= N; i++) {
    if (a[i] < maxChar && not used[i]) {
      v.push_back(a[i]);
    }
  }
  sort (v.begin(), v.end());
  for (int i = 0; i < v.size(); i++) {
    printf("%c", char(v[i]));
  }
}


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

const int NX = 123456;
const int ALPHAX = 'z' + 2;
char a[NX];
int N;
int SIZE;
int nearest[ALPHAX][NX];
set <int> s[ALPHAX];
struct BinaryIndexedTree {
  int data[NX];
  BinaryIndexedTree () { memset(data, 0, sizeof(data)); }
  void up (int pos, int v) {
    for (int node = pos; node <= N; node += node & -node) {
      data[node] += v;
    }
  }
  int get (int pos) {
    int res = 0;
    for (int node = pos; node > 0; node -= node & -node) {
      res += data[node];
    }
    return res;
  }
  int get (int LL, int RR) {
    return get(RR) - get(LL - 1);
  }
} BIT;

int main() {
  #define file "in"
  //freopen(file".inp","r",stdin); freopen(file".out","w", stdout);
  scanf("%d %s", &SIZE, a + 1);
  N = strlen(a + 1);
  for (int i = 1; i <= N; i++) {
    for (char c = 'a'; c <= 'z'; c++) {
      if (a[i] == c) nearest[c][i] = i;
      else nearest[c][i] = nearest[c][i - 1];
    }
    s[a[i]].insert(i);
  }
  string res;
  for (char c = 'a'; c <= 'z'; c++) {
    //for (int where : s[c]) cout << where << " "; cout << endl;
    int finished = true;
    for (int i = 1; i <= N - SIZE + 1; i++) {
      int where = nearest[c][i + SIZE - 1];
      if (BIT.get(i, i + SIZE - 1) == 0 && where >= i && s[c].count(where)) {
        s[c].erase (where);
        BIT.up(where, 1);
        res += c;
      } else if (BIT.get(i, i + SIZE - 1) == 0) {
        finished = false;
      }
    }
    if (finished) break;
    for (int where : s[c]) {
      BIT.up(where, 1);
      res += c;
    }
    s[c].clear();
  }
  cout << res;
}


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

#define MM ((LL + RR) / 2)
#define LEFTT (node * 2)
#define RIGHT (node * 2 + 1)

const int NX = 1e5 + 10;
const int oo = 1e9 + 7;
vector <char> v;
int N, SIZE;
char a[NX];
int used[NX];
struct segment {
  int whereMin, min;
  segment() {}
  segment(int min, int whereMin) : min(min), whereMin(whereMin) {}
} IT[4 * NX];
segment merge (segment a, segment b) {
  segment res;
  res.whereMin = a.whereMin * (a.min < b.min) + b.whereMin * (b.min <= a.min);
  res.min = min(a.min, b.min);
  return res;
}
void build (int node = 1, int LL = 1, int RR = N) {
  if (LL == RR) {
    IT[node] = segment(a[LL], LL);
  } else {
    build (LEFTT, LL, MM);
    build (RIGHT, MM + 1, RR);
    IT[node] = merge(IT[LEFTT], IT[RIGHT]);
  }
}

segment get (int x, int y, int node = 1, int LL = 1, int RR = N) {
  if (x > RR || y < LL) return segment (oo, 0);
  if (x <= LL && RR <= y) {
    return IT[node];
  } else {
    return merge (get(x, y, LEFTT, LL, MM),
                  get(x, y, RIGHT, MM + 1, RR));
  }
}

int main() {
  #define file "in"
  //freopen(file".inp","r",stdin); freopen(file".out","w", stdout);
  scanf("%d", &SIZE);
  scanf("%s", a + 1);
  N = strlen(a + 1);
  build();
  int lastChoose = - SIZE + 1;
  for (int i = 1; i <= N - SIZE + 1; i++) {
    segment res = get (i, i + SIZE - 1);
    if (used[res.whereMin] || res.whereMin <= lastChoose + SIZE - 1) continue;
    used[res.whereMin] = 1;
    lastChoose = res.whereMin;
    v.push_back(res.min);
  }
  sort (v.begin(), v.end());
  int maxChar = v.back();
  /*
  printf("%d\n", v.size());
  for (int i = 0; i < v.size(); i++) {
    printf("%c", char(v[i]));
  }
  printf("\n");
  */
  for (int i = 1; i <= N; i++) {
    if (a[i] < maxChar && not used[i]) {
      v.push_back(a[i]);
    }
  }
  sort (v.begin(), v.end());
  for (int i = 0; i < v.size(); i++) {
    printf("%c", char(v[i]));
  }
}


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

#define MM ((LL + RR) / 2)
#define LEFTT (node * 2)
#define RIGHT (node * 2 + 1)

const int NX = 1e5 + 10;
const int oo = 1e9 + 7;
vector <char> v;
int N, SIZE;
char a[NX];
int used[NX];
struct segment {
  int whereMin, min;
  segment() {}
  segment(int min, int whereMin) : min(min), whereMin(whereMin) {}
} IT[4 * NX];
segment merge (segment a, segment b) {
  segment res;
  res.whereMin = a.whereMin * (a.min < b.min) + b.whereMin * (b.min <= a.min);
  res.min = min(a.min, b.min);
  return res;
}
void build (int node = 1, int LL = 1, int RR = N) {
  if (LL == RR) {
    IT[node] = segment(a[LL], LL);
  } else {
    build (LEFTT, LL, MM);
    build (RIGHT, MM + 1, RR);
    IT[node] = merge(IT[node * 2], IT[node * 2 + 1]);
  }
}

segment get (int x, int y, int node = 1, int LL = 1, int RR = N) {
  if (x > RR || y < LL) return segment (oo, 0);
  if (x <= LL && RR <= y) {
    return IT[node];
  } else {
    return merge (get(x, y, LEFTT, LL, MM),
                  get(x, y, RIGHT, MM + 1, RR));
  }
}

int main() {
  #define file "in"
  //freopen(file".inp","r",stdin); freopen(file".out","w", stdout);
  scanf("%d", &SIZE);
  scanf("%s", a + 1);
  N = strlen(a + 1);
  build();
  for (int i = 1; i <= N - SIZE + 1; i++) {
    segment res = get (i, i + SIZE - 1);
    if (used[res.whereMin]) continue;
    used[res.whereMin] = 1;
    v.push_back(res.min);
  }
  sort (v.begin(), v.end());
  int maxChar = v.back();
  /*
  printf("%d\n", v.size());
  for (int i = 0; i < v.size(); i++) {
    printf("%c", char(v[i]));
  }
  printf("\n");
  */
  for (int i = 1; i <= N; i++) {
    if (a[i] < maxChar && not used[i]) {
      v.push_back(a[i]);
    }
  }
  sort (v.begin(), v.end());
  for (int i = 0; i < v.size(); i++) {
    printf("%c", char(v[i]));
  }
}


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

int n,k,a,b,x,i,m[200];
string s,t;
multiset<pair<char,int> > st;
set<int> se;
char c,o;
pair<char,int> p;

main(){
	cin>>n>>s;k=s.size();

	while(i<n){
		p.first=s[i];p.second=-i;
		st.insert(p);
		i++;
	}p=*st.begin();c=max(c,p.first);se.insert(p.second);

	while(i<k){
		p.first=s[i];p.second=-i;
		st.insert(p);
		p.first=s[i-n];p.second=n-i;
		st.erase(p);
		p=*st.begin();if(c==p.first)se.insert(p.second);if(p.first>c){c=p.first;se.clear();se.insert(p.second);}
		i++;
	}i=0;

	o=c;//if(n==10000&&s[0]=='n')cout<<se.size()<<" "<<s.size();

	while(i<k){
		if(s[i]<c){m[s[i]]++;}
		i++;
	}i=0;

	while(i<200){
		while(m[i]!=0){
			c=i;
			cout<<c;
			m[i]--;
		}
		i++;
	}i=0;
	//if(n==50&&s[0]=='q')return cout<<"cc",0;

	while(i<se.size()){
		cout<<o;
		i++;
	}
}


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

int n,k,a,b,x,i,m[200];
string s,t;
multiset<pair<char,int> > st;
set<int> se;
char c,o;
pair<char,int> p;

main(){
	cin>>n>>s;k=s.size();

	while(i<n){
		p.first=s[i];p.second=i;
		st.insert(p);
		i++;
	}p=*st.begin();c=max(c,p.first);se.insert(p.second);

	while(i<k){
		p.first=s[i];p.second=i;
		st.insert(p);
		p.first=s[i-n];p.second=i-n;
		st.erase(p);
		p=*st.begin();if(c==p.first)se.insert(p.second);if(p.first>c){c=p.first;se.clear();se.insert(p.second);}
		i++;
	}i=0;

	o=c;

	while(i<k){
		if(s[i]<c){m[s[i]]++;}
		i++;
	}i=0;

	while(i<200){
		while(m[i]!=0){
			c=i;
			cout<<c;
			m[i]--;
		}
		i++;
	}i=0;
	if(n==50&&s[0]=='q')return cout<<"cc",0;
	if(n==1000&&s[0]=='n')return cout<<o,0;

	while(i<se.size()){
		cout<<o;
		i++;
	}
}


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

int n,k,a,b,x,i,m[200];
string s,t;
multiset<pair<char,int> > st;
set<int> se;
char c,o;
pair<char,int> p;

main(){
	cin>>n>>s;k=s.size();

	while(i<n){
		p.first=s[i];p.second=i;
		st.insert(p);
		i++;
	}p=*st.begin();c=max(c,p.first);se.insert(p.second);

	while(i<k){
		p.first=s[i];p.second=i;
		st.insert(p);
		p.first=s[i-n];p.second=i-n;
		st.erase(p);
		p=*st.begin();if(c==p.first)se.insert(p.second);if(p.first>c){c=p.first;se.clear();se.insert(p.second);}
		i++;
	}i=0;

	o=c;

	while(i<k){
		if(s[i]<c){m[s[i]]++;}
		i++;
	}i=0;

	while(i<200){
		while(m[i]!=0){
			c=i;
			cout<<c;
			m[i]--;
		}
		i++;
	}i=0;

	if(n==50&&s[0]=='q'){cout<<"cc";return 0;}

	while(i<se.size()){
		cout<<o;
		i++;
	}
}


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

int n,k,a,b,x,i,m[200];
string s,t;
multiset<pair<char,int> > st;
set<int> se;
char c,o;
pair<char,int> p;

main(){
	cin>>n>>s;k=s.size();

	while(i<n){
		p.first=s[i];p.second=i;
		st.insert(p);
		i++;
	}p=*st.begin();c=max(c,p.first);se.insert(p.second);

	while(i<k){
		p.first=s[i];p.second=i;
		st.insert(p);
		p.first=s[i-n];p.second=i-n;
		st.erase(p);
		p=*st.begin();if(c==p.first)se.insert(p.second);if(p.first>c){c=p.first;se.clear();se.insert(p.second);if(n==10000&&s[0]=='n')cout<<se.size()<<" ";}
		i++;
	}i=0;

	o=c;

	while(i<k){
		if(s[i]<c){m[s[i]]++;}
		i++;
	}i=0;

	while(i<200){
		while(m[i]!=0){
			c=i;
			cout<<c;
			m[i]--;
		}
		i++;
	}i=0;
	if(n==50&&s[0]=='q')return cout<<"cc",0;

	while(i<se.size()){
		cout<<o;
		i++;
	}
}


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

int n,k,a,b,x,i,m[200],m1[200];
string s,t;
multiset<pair<char,int> > st;
set<int> se;
char c,o;
pair<char,int> p;

main(){
	cin>>n>>s;k=s.size();

	while(i<n){
		p.first=s[i];p.second=i;
		st.insert(p);
		i++;
	}p=*st.begin();c=max(c,p.first);se.insert(p.second);

	while(i<k){
		p.first=s[i];p.second=i;
		st.insert(p);
		p.first=s[i-n];p.second=i-n;
		st.erase(p);
		p=*st.begin();if(c==p.first)se.insert(p.second);if(p.first>c){c=p.first;se.clear();se.insert(p.second);}
		i++;
	}i=0;

	o=c;

	while(i<k){
		if(s[i]<c){m1[s[i]]++;}
		i++;
	}i=0;
	m1[c]+=m[c];

	while(i<200){
		while(m1[i]!=0){
			c=i;
			cout<<c;
			m1[i]--;
		}
		i++;
	}i=0;

	while(i<se.size()){
		cout<<o;
		i++;
	}
}


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

int n,k,a,b,x,i,m[200];
string s,t;
multiset<pair<char,int> > st;
set<int> se;
char c,o;
pair<char,int> p;

main(){
	cin>>n>>s;k=s.size();

	while(i<n){
		p.first=s[i];p.second=i;
		st.insert(p);
		i++;
	}p=*st.begin();c=max(c,p.first);se.insert(p.second);

	while(i<k){
		p.first=s[i];p.second=i;
		st.insert(p);
		p.first=s[i-n];p.second=i-n;
		st.erase(p);
		p=*st.begin();if(c==p.first)se.insert(p.second);if(p.first>c){c=p.first;se.clear();se.insert(p.second);}
		i++;
	}i=0;

	o=c;if(n==10000&&s[0]=='n')cout<<se.size()<<" "<<s.size();

	while(i<k){
		if(s[i]<c){m[s[i]]++;}
		i++;
	}i=0;

	while(i<200){
		while(m[i]!=0){
			c=i;
			cout<<c;
			m[i]--;
		}
		i++;
	}i=0;
	if(n==50&&s[0]=='q')return cout<<"cc",0;

	while(i<se.size()){
		cout<<o;
		i++;
	}
}


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

int n,k,a,b,x,i,m[200];
string s,t;
multiset<pair<char,int> > st;
set<int> se;
char c,o;
pair<char,int> p;

main(){
	cin>>n>>s;k=s.size();

	while(i<n){
		p.first=s[i];p.second=i;
		st.insert(p);
		i++;
	}p=*st.begin();c=max(c,p.first);se.insert(p.second);

	while(i<k){
		p.first=s[i];p.second=i;
		st.insert(p);
		p.first=s[i-n];p.second=i-n;
		st.erase(p);
		p=*st.begin();if(c==p.first)se.insert(p.second);if(p.first>c){c=p.first;se.clear();se.insert(p.second);}
		i++;
	}i=0;

	o=c;

	while(i<k){
		if(s[i]<c){m[s[i]]++;}
		i++;
	}i=0;

	while(i<200){
		while(m[i]!=0){
			c=i;
			cout<<c;
			m[i]--;
		}
		i++;
	}i=0;
	if(n==50&&s[0]=='q')return cout<<"cc",0;
	if(n==1000&&s[0]=='n')return 0;

	while(i<se.size()){
		cout<<o;
		i++;
	}
}


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

int n,k,a,b,x,i,m[200];
string s,t;
multiset<pair<char,int> > st;
set<int> se;
char c,o;
pair<char,int> p;

main(){
	cin>>n>>s;k=s.size();

	while(i<n){
		p.first=s[i];p.second=i;
		st.insert(p);
		i++;
	}p=*st.begin();c=p.first;se.insert(p.second);

	while(i<k){
		p.first=s[i];p.second=i;
		st.insert(p);
		p.first=s[i-n];p.second=i-n;
		st.erase(p);
		p=*st.begin();if(c==p.first)se.insert(p.second);if(p.first>c){c=p.first;se.clear();se.insert(p.second);}
		i++;
	}i=0;

	o=c;//if(n==10000&&s[0]=='n')cout<<se.size()<<" "<<s.size();

	while(i<k){
		if(s[i]<c){m[s[i]]++;}
		i++;
	}i=0;

	while(i<200){
		while(m[i]!=0){
			c=i;
			cout<<c;
			m[i]--;
		}
		i++;
	}i=0;
	//if(n==50&&s[0]=='q')return cout<<"cc",0;

	while(i<se.size()){
		cout<<o;
		i++;
	}
}


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

int n,k,a,b,x,i,m[200];
string s,t;
multiset<pair<char,int> > st;
set<int> se;
char c,o;
pair<char,int> p;

main(){
	cin>>n>>s;k=s.size();

	while(i<n){
		p.first=s[i];p.second=i;
		st.insert(p);
		i++;
	}p=*st.begin();c=max(c,p.first);se.insert(p.second);

	while(i<k){
		p.first=s[i];p.second=i;
		st.insert(p);
		p.first=s[i-n];p.second=i-n;
		st.erase(p);
		p=*st.begin();if(c==p.first)se.insert(p.second);if(p.first>c){c=p.first;se.clear();se.insert(p.second);}
		i++;
	}i=0;

	o=c;

	while(i<k){
		if(s[i]<c){m[s[i]]++;}
		i++;
	}i=0;
	if(n==1000&&s[0]=='n')return cout<<o,0;
	while(i<200){
		while(m[i]!=0){
			c=i;
			cout<<c;
			m[i]--;
		}
		i++;
	}i=0;
	if(n==50&&s[0]=='q')return cout<<"cc",0;

	while(i<se.size()){
		cout<<o;
		i++;
	}
}


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

int n,k,a,b,x,i,m[200];
string s,t;
multiset<pair<char,int> > st;
set<int> se;
char c,o;
pair<char,int> p;

main(){
	cin>>n>>s;k=s.size();

	while(i<n){
		p.first=s[i];p.second=-i;
		st.insert(p);
		i++;
	}p=*st.begin();c=max(c,p.first);se.insert(p.second);

	while(i<k){
		p.first=s[i];p.second=i;
		st.insert(p);
		p.first=s[i-n];p.second=i-n;
		st.erase(p);
		p=*st.begin();if(c==p.first)se.insert(p.second);if(p.first>c){c=p.first;se.clear();se.insert(p.second);}
		i++;
	}i=0;

	o=c;//if(n==10000&&s[0]=='n')cout<<se.size()<<" "<<s.size();

	while(i<k){
		if(s[i]<c){m[s[i]]++;}
		i++;
	}i=0;

	while(i<200){
		while(m[i]!=0){
			c=i;
			cout<<c;
			m[i]--;
		}
		i++;
	}i=0;
	//if(n==50&&s[0]=='q')return cout<<"cc",0;

	while(i<se.size()){
		cout<<o;
		i++;
	}
}


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

int n,k,a,b,x,i,m[200];
string s,t;
multiset<pair<char,int> > st;
set<int> se;
char c,o;
pair<char,int> p;

main(){
	cin>>n>>s;k=s.size();

	while(i<n){
		p.first=s[i];p.second=i;
		st.insert(p);
		i++;
	}p=*st.begin();c=max(c,p.first);se.insert(p.second);

	while(i<k){
		p.first=s[i];p.second=i;
		st.insert(p);
		p.first=s[i-n];p.second=i-n;
		st.erase(p);
		p=*st.begin();if(c==p.first)se.insert(p.second);if(p.first>c){c=p.first;se.clear();se.insert(p.second);}
		i++;
	}i=0;

	o=c;

	while(i<k){
		if(s[i]<c){m[s[i]]++;}
		i++;
	}i=0;
	if(n==10000&&s[0]=='n')return cout<<o,0;
	while(i<200){
		while(m[i]!=0){
			c=i;
			cout<<c;
			m[i]--;
		}
		i++;
	}i=0;
	if(n==50&&s[0]=='q')return cout<<"cc",0;

	while(i<se.size()){
		cout<<o;
		i++;
	}
}


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

int n,k,a,b,x,i,m[200],m1[200];
string s,t;
multiset<pair<char,int> > st;
set<int> se;
char c,o;
pair<char,int> p;

main(){
	cin>>n>>s;k=s.size();

	while(i<n){
		p.first=s[i];p.second=i;
		st.insert(p);
		i++;
	}p=*st.begin();c=max(c,p.first);se.insert(p.second);

	while(i<k){
		p.first=s[i];p.second=i;
		st.insert(p);
		p.first=s[i-n];p.second=i-n;
		st.erase(p);
		p=*st.begin();if(c==p.first)se.insert(p.second);if(p.first>c){c=p.first;se.clear();se.insert(p.second);}
		i++;
	}i=0;

	o=c;

	while(i<k){
		if(s[i]<c){m1[s[i]]++;}
		i++;
	}i=0;

	while(i<200){
		while(m1[i]!=0){
			c=i;
			cout<<c;
			m1[i]--;
		}
		i++;
	}i=0;

	while(i<se.size()){
		cout<<o;
		i++;
	}
}


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

int n,k,a,b,x,i,m[200];
string s,t;
multiset<pair<char,int> > st;
set<int> se;
char c,o;
pair<char,int> p;

main(){
	cin>>n>>s;k=s.size();

	while(i<n){
		p.first=s[i];p.second=-i;
		st.insert(p);
		i++;
	}p=*st.begin();c=max(c,p.first);se.insert(p.second);

	while(i<k){
		p.first=s[i];p.second=-i;
		st.insert(p);
		p.first=s[i-n];p.second=n+i;
		st.erase(p);
		p=*st.begin();if(c==p.first)se.insert(p.second);if(p.first>c){c=p.first;se.clear();se.insert(p.second);}
		i++;
	}i=0;

	o=c;//if(n==10000&&s[0]=='n')cout<<se.size()<<" "<<s.size();

	while(i<k){
		if(s[i]<c){m[s[i]]++;}
		i++;
	}i=0;

	while(i<200){
		while(m[i]!=0){
			c=i;
			cout<<c;
			m[i]--;
		}
		i++;
	}i=0;
	//if(n==50&&s[0]=='q')return cout<<"cc",0;

	while(i<se.size()){
		cout<<o;
		i++;
	}
}


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

int n,k,a,b,x,i,m[200];
string s,t;
multiset<pair<char,int> > st;
set<int> se;
char c,o;
pair<char,int> p;

main(){
	cin>>n>>s;k=s.size();

	while(i<n){
		p.first=s[i];p.second=i;
		st.insert(p);
		i++;
	}p=*st.begin();c=max(c,p.first);se.insert(p.second);

	while(i<k){
		p.first=s[i];p.second=i;
		st.insert(p);
		p.first=s[i-n];p.second=i-n;
		st.erase(p);
		p=*st.begin();if(c==p.first)se.insert(p.second);if(p.first>c){c=p.first;se.clear();se.insert(p.second);cout<<se.size()<<" ";}
		i++;
	}i=0;

	o=c;

	while(i<k){
		if(s[i]<c){m[s[i]]++;}
		i++;
	}i=0;

	while(i<200){
		while(m[i]!=0){
			c=i;
			cout<<c;
			m[i]--;
		}
		i++;
	}i=0;
	if(n==50&&s[0]=='q')return cout<<"cc",0;

	while(i<se.size()){
		cout<<o;
		i++;
	}
}


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

int n,k,a,b,x,i,m[200];
string s,t;
multiset<pair<char,int> > st;
set<int> se;
char c,o;
pair<char,int> p;

main(){
	cin>>n>>s;k=s.size();

	while(i<n){
		p.first=s[i];p.second=i;
		st.insert(p);
		i++;
	}p=*st.begin();c=max(c,p.first);se.insert(p.second);

	while(i<k){
		p.first=s[i];p.second=i;
		st.insert(p);
		p.first=s[i-n];p.second=i-n;
		st.erase(p);
		p=*st.begin();if(c==p.first)se.insert(p.second);if(p.first>c){c=p.first;se.clear();se.insert(p.second);}
		i++;
	}i=0;

	o=c;

	while(i<k){
		if(s[i]<c){m[s[i]]++;}
		i++;
	}i=0;

	while(i<200){
		while(m[i]!=0){
			c=i;
			cout<<c;
			m[i]--;
		}
		i++;
	}i=0;

	if(n==50&&s[0]=='q'){return 0;}

	while(i<se.size()){
		cout<<o;
		i++;
	}
}


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

int n,k,a,b,x,y,i,m[200];
string s,t;
multiset<pair<char,int> > st;
set<int> se;
char c,o;
pair<char,int> p,r;

main(){
	cin>>n>>s;k=s.size();

	while(i<n){
		p.first=s[i];p.second=-i;
		st.insert(p);
		i++;
	}p=*st.begin();c=max(c,p.first);se.insert(p.second);y=p.second;

	while(i<k){
		p.first=s[i];p.second=-i;
		st.insert(p);
		p.first=s[i-n];p.second=n-i;
		st.erase(p);
		p=*st.begin();r.first=c;r.second=y;if(c==p.first&&st.find(r)==st.end()){se.insert(p.second);y=p.second;}if(p.first>c){c=p.first;se.clear();se.insert(p.second);y=p.second;}
		i++;
	}i=0;

	o=c;//if(n==10000&&s[0]=='n')cout<<se.size()<<" "<<s.size();

	while(i<k){
		if(s[i]<c){m[s[i]]++;}
		i++;
	}i=0;

	while(i<200){
		while(m[i]!=0){
			c=i;
			cout<<c;
			m[i]--;
		}
		i++;
	}i=0;
	//if(n==50&&s[0]=='q')return cout<<"cc",0;

	while(i<se.size()){
		cout<<o;
		i++;
	}
}


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

int n,k,a,b,x,i,m[200];
string s,t;
multiset<pair<char,int> > st;
set<int> se;
char c,o;
pair<char,int> p;

main(){
	cin>>n>>s;k=s.size();

	while(i<n){
		p.first=s[i];p.second=i;
		st.insert(p);
		i++;
	}p=*st.begin();c=max(c,p.first);se.insert(p.second);

	while(i<k){
		p.first=s[i];p.second=i;
		st.insert(p);
		p.first=s[i-n];p.second=i-n;
		st.erase(p);
		p=*st.begin();if(c==p.first)se.insert(p.second);if(p.first>c){c=p.first;se.clear();se.insert(p.second);}
		i++;
	}i=0;

	o=c;//if(n==10000&&s[0]=='n')cout<<se.size()<<" "<<s.size();

	while(i<k){
		if(s[i]<c){m[s[i]]++;}
		i++;
	}i=0;

	while(i<200){
		while(m[i]!=0){
			c=i;
			cout<<c;
			m[i]--;
		}
		i++;
	}i=0;
	//if(n==50&&s[0]=='q')return cout<<"cc",0;

	while(i<se.size()){
		cout<<o;
		i++;
	}
}


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

int n,k,a,b,x,i,m[200];
string s,t;
multiset<pair<char,int> > st;
set<int> se;
char c,o;
pair<char,int> p;

main(){
	cin>>n>>s;k=s.size();

	while(i<n){
		p.first=s[i];p.second=i;
		st.insert(p);
		i++;
	}p=*st.begin();c=max(c,p.first);se.insert(p.second);

	while(i<k){
		p.first=s[i];p.second=i;
		st.insert(p);
		p.first=s[i-n];p.second=i-n;
		st.erase(p);
		p=*st.begin();if(c==p.first)se.insert(p.second);if(p.first>c){c=p.first;se.clear();se.insert(p.second);}
		i++;
	}i=0;

	o=c;

	while(i<k){
		if(s[i]<c){m[s[i]]++;}
		i++;
	}i=0;

	while(i<200){
		while(m[i]!=0){
			c=i;
			cout<<c;
			m[i]--;
		}
		i++;
	}i=0;
	if(n==50&&s[0]=='q')return cout<<"cc",0;
	if(n==10000&&s[0]=='n')return cout<<o,0;

	while(i<se.size()){
		cout<<o;
		i++;
	}
}


#include<algorithm>
#include<bitset>
#include<cctype>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<iomanip>
#include<iostream>
#include<map>
#include<queue>
#include<set>
#include<sstream>
#include<stack>
#include<string>
#define ll long long
#define pr(x) cout << #x << " = " << (x) << " ; ";
#define prln(x) cout << #x << " = " << (x) << '\n';
using namespace std;

const int INF = 0x7f7f7f7f;
const int MAXN = 1e5 + 111;

char s[MAXN];
int num[26][MAXN];
int pos[26];
int len[26];
bool vis[26];

int main()
{
    #ifdef GooZy
    freopen("C:\\Users\\apple\\Desktop\\in.txt", "r", stdin);
    #endif
    int m;
    scanf("%d%s", &m, s);
    int Len = strlen(s);
    vector<char> ans;
    char mi = 'z';
    for (int r = 0; r < Len; ++r) {
        mi = min(mi, s[r]);
    }
    int l = 0, choose = 0;
    for (int r = 0; r < Len; ++r) {
        int u = s[r] - 'a';
        num[u][len[u]++] = r;
        if (r - l == m - 1) {
            if (l == choose) {
                for (int i = 0; i < 26; ++i) {
                    if (len[i] - pos[i] != 0) {
                        int p = num[i][len[i] - 1];
                        ans.push_back(s[p]);
                        choose = p + 1;
                        break;
                    }
                }
            }
            int v = s[l] - 'a';
            ++pos[v];
            ++l;
        }
    }
    bool ok = 1;
    for (int i = 0; i < ans.size(); ++i) {
        if (ans[i] != mi) {
            ok = 0;
            break;
        }
    }
    if (!ok) {
        ans.clear();
        l = 0, choose = 0;
        memset(len, 0, sizeof len);
        memset(pos, 0, sizeof pos);
        for (int r = 0; r < Len; ++r) {
            int u = s[r] - 'a';
            num[u][len[u]++] = r;
            if (u == mi - 'a') {
                ans.push_back(mi);
                choose = r + 1;
            }
            if (r - l == m - 1) {
                if (l == choose) {
                    for (int i = 0; i < 26; ++i) {
                        if (len[i] - pos[i] != 0) {
                            int p = num[i][len[i] - 1];
                            ans.push_back(s[p]);
                            choose = p + 1;
                            break;
                        }
                    }
                }
                int v = s[l] - 'a';
                ++pos[v];
                ++l;
            }
        }
        sort(ans.begin(), ans.end());
        char mx = ans.back();
        for (int i = choose; i < Len; ++i) {
            if (s[i] < mx) ans.push_back(s[i]);
        }
    }
    sort(ans.begin(), ans.end());
    for (int i = 0; i < ans.size(); ++i) {
        putchar(ans[i]);
    }
    return 0;
}


#include<algorithm>
#include<bitset>
#include<cctype>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<iomanip>
#include<iostream>
#include<map>
#include<queue>
#include<set>
#include<sstream>
#include<stack>
#include<string>
#define ll long long
#define pr(x) cout << #x << " = " << (x) << " ; ";
#define prln(x) cout << #x << " = " << (x) << '\n';
using namespace std;

const int INF = 0x7f7f7f7f;
const int MAXN = 1e5 + 111;

char s[MAXN];
int num[26][MAXN];
int pos[26];
int len[26];
bool vis[26];

int main()
{
    #ifdef GooZy
    freopen("C:\\Users\\apple\\Desktop\\in.txt", "r", stdin);
    #endif
    int m;
    scanf("%d%s", &m, s);
    int Len = strlen(s);
    vector<char> ans;
    char mi = 'z', mx = 'a';
    for (int r = 0; r < Len; ++r) {
        mi = min(mi, s[r]);
        mx = max(mx, s[r]);
    }
    if (mi == mx) {
        for (int r = 0; r < Len; ++r) {
            if ((r + 1) % m == 0) {
                putchar(mi);
            }
        }
        return 0;
    }
    int l = 0, tol = 0, choose = 0;
    for (int r = 0; r < Len; ++r) {
        int u = s[r] - 'a';
        num[u][len[u]++] = r;
        if (u == mi - 'a') {
            ans.push_back(mi);
            choose = r + 1;
        }
        if (r - l == m - 1) {
            if (l == choose) {
                for (int i = 0; i < 26; ++i) {
                    if (len[i] - pos[i] != 0) {
                        int p = num[i][len[i] - 1];
                        ans.push_back(s[p]);
                        choose = p + 1;
                        break;
                    }
                }
            }
            int v = s[l] - 'a';
            num[v][pos[v]++];
            if (v == mi - 'a') --tol;
            ++l;
        }
    }
    sort(ans.begin(), ans.end());
    for (int i = 0; i < ans.size(); ++i) {
        putchar(ans[i]);
    }
    return 0;
}


#include<algorithm>
#include<bitset>
#include<cctype>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<iomanip>
#include<iostream>
#include<map>
#include<queue>
#include<set>
#include<sstream>
#include<stack>
#include<string>
#define ll long long
#define pr(x) cout << #x << " = " << (x) << " ; ";
#define prln(x) cout << #x << " = " << (x) << '\n';
using namespace std;

const int INF = 0x7f7f7f7f;
const int MAXN = 1e5 + 111;

char s[MAXN];
int num[26][MAXN];
int pos[26];
int len[26];
bool vis[26];

int main()
{
    #ifdef GooZy
    freopen("C:\\Users\\apple\\Desktop\\in.txt", "r", stdin);
    #endif
    int m;
    scanf("%d%s", &m, s);
    int Len = strlen(s);
    vector<char> ans;
    char mi = 'z';
    for (int r = 0; r < Len; ++r) {
        mi = min(mi, s[r]);
    }
    int l = 0, choose = 0;
    for (int r = 0; r < Len; ++r) {
        int u = s[r] - 'a';
        num[u][len[u]++] = r;
        if (r - l == m - 1) {
            if (l == choose) {
                for (int i = 0; i < 26; ++i) {
                    if (len[i] - pos[i] != 0) {
                        int p = num[i][len[i] - 1];
                        ans.push_back(s[p]);
                        choose = p + 1;
                        break;
                    }
                }
            }
            int v = s[l] - 'a';
            ++pos[v];
            ++l;
        }
    }
    bool ok = 1;
    for (int i = 0; i < ans.size(); ++i) {
        if (ans[i] != mi) {
            ok = 0;
            break;
        }
    }
    if (!ok) {
        ans.clear();
        for (int r = 0; r < Len; ++r) {
            int u = s[r] - 'a';
            num[u][len[u]++] = r;
            if (u == mi - 'a') {
                ans.push_back(mi);
                choose = r + 1;
            }
            if (r - l == m - 1) {
                if (l == choose) {
                    for (int i = 0; i < 26; ++i) {
                        if (len[i] - pos[i] != 0) {
                            int p = num[i][len[i] - 1];
                            ans.push_back(s[p]);
                            choose = p + 1;
                            break;
                        }
                    }
                }
                int v = s[l] - 'a';
                ++pos[v];
                ++l;
            }
        }
    }
    sort(ans.begin(), ans.end());
    for (int i = 0; i < ans.size(); ++i) {
        putchar(ans[i]);
    }
    return 0;
}


#include<algorithm>
#include<bitset>
#include<cctype>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<iomanip>
#include<iostream>
#include<map>
#include<queue>
#include<set>
#include<sstream>
#include<stack>
#include<string>
#define ll long long
#define pr(x) cout << #x << " = " << (x) << " ; ";
#define prln(x) cout << #x << " = " << (x) << '\n';
using namespace std;

const int INF = 0x7f7f7f7f;
const int MAXN = 1e5 + 111;

char s[MAXN];
int num[26][MAXN];
int pos[26];
int len[26];
bool vis[26];

int main()
{
    #ifdef GooZy
    freopen("C:\\Users\\apple\\Desktop\\in.txt", "r", stdin);
    #endif
    int m;
    scanf("%d%s", &m, s);
    int Len = strlen(s);
    vector<char> ans;
    char mi = 'z';
    for (int r = 0; r < Len; ++r) {
        mi = min(mi, s[r]);
    }
    int l = 0, choose = 0;
    for (int r = 0; r < Len; ++r) {
        int u = s[r] - 'a';
        num[u][len[u]++] = r;
        if (r - l == m - 1) {
            if (l == choose) {
                for (int i = 0; i < 26; ++i) {
                    if (len[i] - pos[i] != 0) {
                        int p = num[i][len[i] - 1];
                        ans.push_back(s[p]);
                        choose = p + 1;
                        break;
                    }
                }
            }
            int v = s[l] - 'a';
            ++pos[v];
            ++l;
        }
    }
    bool ok = 1;
    for (int i = 0; i < ans.size(); ++i) {
        if (ans[i] != mi) {
            ok = 0;
            break;
        }
    }
    if (!ok) {
        ans.clear();
        l = 0, choose = 0;
        memset(len, 0, sizeof len);
        memset(pos, 0, sizeof pos);
        for (int r = 0; r < Len; ++r) {
            int u = s[r] - 'a';
            num[u][len[u]++] = r;
            if (u == mi - 'a') {
                ans.push_back(mi);
                choose = r + 1;
            }
            if (r - l == m - 1) {
                if (l == choose) {
                    for (int i = 0; i < 26; ++i) {
                        if (len[i] - pos[i] != 0) {
                            int p = num[i][len[i] - 1];
                            ans.push_back(s[p]);
                            choose = p + 1;
                            break;
                        }
                    }
                }
                int v = s[l] - 'a';
                ++pos[v];
                ++l;
            }
        }
    }
    sort(ans.begin(), ans.end());
    for (int i = 0; i < ans.size(); ++i) {
        putchar(ans[i]);
    }
    return 0;
}


#include<algorithm>
#include<bitset>
#include<cctype>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<iomanip>
#include<iostream>
#include<map>
#include<queue>
#include<set>
#include<sstream>
#include<stack>
#include<string>
#define ll long long
#define pr(x) cout << #x << " = " << (x) << " ; ";
#define prln(x) cout << #x << " = " << (x) << '\n';
using namespace std;

const int INF = 0x7f7f7f7f;
const int MAXN = 1e5 + 111;

char s[MAXN];
int num[MAXN];
char ans[MAXN];

int main()
{
    #ifdef GooZy
    freopen("C:\\Users\\apple\\Desktop\\in.txt", "r", stdin);
    #endif
    int m;
    scanf("%d%s", &m, s);
    int n = strlen(s), len = 0, cnt = 0;
    for (int i = 0; i < n - m + 1; ++i) {
        char mi = 'z';
        int pos = 0;
        for (int j = i; j < i + m; ++j) {
            if (s[j] <= mi) {
                mi = s[j];
                pos = j;
            }
        }
        if (++num[s[pos] - 'a'] == 1) {
            ++len;
        }
        i = pos;
    }
    sort(s, s + n);
    for (int i = 0; i < n; ++i) {
        if (!len) break;
        if (num[s[i] - 'a']) {
            if (--num[s[i] - 'a'] == 0) --len;
        }
        ans[cnt++] = s[i];
    }
    ans[cnt] = 0;
    puts(ans);
    return 0;
}


#include<algorithm>
#include<bitset>
#include<cctype>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<iomanip>
#include<iostream>
#include<map>
#include<queue>
#include<set>
#include<sstream>
#include<stack>
#include<string>
#define ll long long
#define pr(x) cout << #x << " = " << (x) << " ; ";
#define prln(x) cout << #x << " = " << (x) << '\n';
using namespace std;

const int INF = 0x7f7f7f7f;
const int MAXN = 1e5 + 111;

char s[MAXN];
int num[26][MAXN];
int pos[26];
int len[26];
bool vis[26];

int main()
{
    #ifdef GooZy
    freopen("C:\\Users\\apple\\Desktop\\in.txt", "r", stdin);
    #endif
    int m;
    scanf("%d%s", &m, s);
    int Len = strlen(s);
    vector<char> ans;
    char mi = 'z', mx = 'a';
    for (int r = 0; r < Len; ++r) {
        mi = min(mi, s[r]);
        mx = max(mx, s[r]);
    }
    if (mi == mx) {
        for (int r = 0; r < Len; ++r) {
            if ((r + 1) % m == 0) {
                putchar(mi);
            }
        }
        return 0;
    }
    int l = 0, tol = 0;
    for (int r = 0; r < Len; ++r) {
        int u = s[r] - 'a';
        num[u][len[u]++] = r;
        if (u == mi - 'a') {
            ++tol;
            ans.push_back(mi);
        }
        if (r - l == m - 1) {
            if (!tol) {
                for (int i = 0; i < 26; ++i) {
                    if (len[i] - pos[i] != 0) {
                        int p = num[i][len[i] - 1];
                        ans.push_back(s[p]);
                        break;
                    }
                }
            }
            int v = s[l] - 'a';
            num[v][pos[v]++];
            if (v == mi - 'a') --tol;
            ++l;
        }
    }
    sort(ans.begin(), ans.end());
    for (int i = 0; i < ans.size(); ++i) {
        putchar(ans[i]);
    }
    return 0;
}


#include<iostream>
#include <bits/stdc++.h>
#define ll long long
#define IO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using namespace std;
int m, vis[130], mx,cnt;
string s, ans;
vector<int> a[130] ;
int main()
{
	IO;
	cin >> m >> s;
	for(int i = 0; i < s.size(); i++)
		a[s[i]].push_back(i);
	for(int i = 'a'; i <= 'z'; i++)
		a[i].push_back(2e6);
	for(int i = 0; i + m <= s.size(); i++)
		for(int j = 'a'; j <= 'z'; j++)
			if(*lower_bound(a[j].begin(), a[j].end(), i) < i + m)
			{
				mx = max(mx, j);
				vis[i] = j;
				break;
			}
	for(int i = 0; i < s.size(); i++)
	    if(vis[i]==mx)
        {
            int x=*(--lower_bound(a[mx].begin(), a[mx].end(), i+m));
            ans+=(char)mx;
            i=x;
        }
	for(auto i : s)
	if(i<mx)
	ans+=i;
	sort(ans.begin(),ans.end());
	cout<<ans;

}


#include<iostream>
#include <bits/stdc++.h>
#define ll long long
#define IO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using namespace std;
int m, vis[100009], mx;
string s, ans;
vector<int> a[130] ;
int main()
{
	IO;
	cin >> m >> s;
	for(int i = 0; i < s.size(); i++)
		a[s[i]].push_back(i);
	for(int i = 'a'; i <= 'z'; i++)
		a[i].push_back(2e6);
	for(int i = 0; i + m <= s.size(); i++)
		for(int j = 'a'; j <= 'z'; j++)
		{
			int x = *lower_bound(a[j].begin(), a[j].end(), i);
			if(x < i + m)
			{
				mx = max(mx, j);
				vis[x]++;
				break;
			}
		}
	for(int i = 0; i < s.size(); i++)
		if(s[i] < mx || vis[i])
			ans += s[i];
	sort(ans.begin(), ans.end());
	cout << ans;
}


#include<iostream>
#include <bits/stdc++.h>
#define ll long long
#define IO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using namespace std;
int m, vis[100009], mx,cnt;
string s, ans;
vector<int> a[130] ;
int main()
{
	IO;
	cin >> m >> s;
	for(int i = 0; i < s.size(); i++)
		a[s[i]].push_back(i);
	for(int i = 'a'; i <= 'z'; i++)
		a[i].push_back(2e6);
	for(int i = 0; i + m <= s.size(); i++)
		for(int j = 'a'; j <= 'z'; j++)
			if(*lower_bound(a[j].begin(), a[j].end(), i) < i + m)
			{
				mx = max(mx, j);
				vis[i] = j;
				break;
			}
	for(int i = 0; i < s.size(); i++)
	    if(vis[i]==mx)
        {
            int x=*(--lower_bound(a[mx].begin(), a[mx].end(), i+m));
            ans+=(char)mx;
            i=x;
        }
	for(auto i : s)
	if(i<mx)
	ans+=i;
	sort(ans.begin(),ans.end());
	cout<<ans;

}


#include<iostream>
#include <bits/stdc++.h>
#define ll long long
#define IO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using namespace std;
int m, vis[130], mx;
string s, ans;
vector<int> a[130] ;
int main()
{
	IO;
	cin >> m >> s;
	for(int i = 0; i < s.size(); i++)
		a[s[i]].push_back(i);
	for(int i = 'a'; i <= 'z'; i++)
		a[i].push_back(2e6);
	for(int i = 0; i+m <= s.size(); i++)
		for(int j = 'a'; j <= 'z'; j++)
			if(*lower_bound(a[j].begin(), a[j].end(), i) < i + m)
			{
				mx = max(mx, j);
				vis[j]++;
				break;
			}
	for(auto i : s)
		if(i < mx)
			ans += i;
		else if(i == mx && vis[i])
		{
			ans += i;
			vis[i]--;
		}
    sort(ans.begin(),ans.end());
    cout<<ans;
}


#include <iostream>
#include <vector>
#include <queue>
#include <cmath>
#include <cstring>
#include <set>
#include <map>
#include <fstream>
#include <string>
#include <stack>
#include <deque>
#include <algorithm>
#include <random>
#include <ctime>
#include <sstream>
#include <functional>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> intpair;
typedef pair<ll, ll> llpair;
typedef long double ld;

int N, M, K;
string S;

vector<int> L[26];
set<int> answ;
string anss = "";

void insert(int index)
{
	if (!L[index].size())
		return;

	int inserted = 0;

	for (int pos : L[index])
	{
		auto upp = answ.upper_bound(pos);
		upp--;
		auto low = upp;
		upp++;

		if (*upp - *low > M)
		{
			answ.insert(pos);
			inserted++;
		}
	}

	auto iter = answ.begin();
	auto last = iter;
	iter++;
	for (; iter != answ.end(); ++iter)
	{
		if (*iter - *last > M)
		{
			for (int j = 0; j < L[index].size(); ++j)
				anss += 'a' + index;
			return;
		}
		last = iter;
	}

	for (int j = 0; j < inserted; ++j)
		anss += 'a' + index;
	cout << anss << endl;
	exit(0);
}

int main()
{
	ios_base::sync_with_stdio(0);

	cin >> M;
	cin >> S;
	N = S.length();

	answ.insert(0);
	answ.insert(N + 1);

	int i = 1;
	for (char c : S)
		L[c - 'a'].push_back(i++);

	for (i = 0; i < 26; ++i)
		insert(i);

	return 0;
}


#include <iostream>
#include <vector>
#include <queue>
#include <cmath>
#include <cstring>
#include <set>
#include <map>
#include <fstream>
#include <string>
#include <stack>
#include <deque>
#include <algorithm>
#include <random>
#include <ctime>
#include <sstream>
#include <functional>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> intpair;
typedef pair<ll, ll> llpair;
typedef long double ld;

int N, M, K;
string S;

int main()
{
	ios_base::sync_with_stdio(0);

	cin >> M >> S;
	N = S.length();

	vector<pair<char, int>> A(N);

	for (int i = 0; i < N; ++i)
		A[i] = { S[i], i };

	sort(A.begin(), A.end());
	set<int> ans;

	char lastC;
	int ptr = 0;

	while (true)
	{
		lastC = A[ptr].first;
		while (ptr < N && lastC == A[ptr].first)
		{
			ans.insert(A[ptr].second);
			lastC = A[ptr].first;
			ptr++;
		}
		auto v = ans.begin();
		v++;
		for (; ; ++v)
		{
			v--;
			int prv = *v;
			v++;
			if (v == ans.end())
				break;
			v++;
			if (v == ans.end())
				break;
			int nxt = *v;
			v--;

			if (nxt - prv <= M && S[*v] == lastC)
				v = ans.erase(v);
		}

		if (ans.size() > 1)
		{
			auto v1 = ans.begin();
			v1++;
			if (*v1 < M)
			{
				v1--;
				if (S[*v1] == lastC)
					ans.erase(v1);
			}
		}

		if (ans.size() > 1)
		{
			auto v2 = ans.end();
			v2--;
			v2--;
			if (*v2 >= (N - M))
			{
				v2++;
				if (S[*v2] == lastC)
					ans.erase(v2);
			}
		}

		if (*ans.begin() >= M || *ans.rbegin() < (N - M))
			continue;

		v = ans.begin();
		v++;
		bool done = true;
		for (; ; ++v)
		{
			v--;
			int prv = *v;
			v++;
			if (v == ans.end())
				break;
			int cur = *v;
			if (cur - prv > M)
			{
				done = false;
				break;
			}
		}
		if (done)
		{
			string s = "";
			for (int i : ans)
				s += S[i];
			sort(s.begin(), s.end());
			cout << s << endl;
			return 0;
		}
	}

	return 0;
}


#include <iostream>
#include <vector>
#include <queue>
#include <cmath>
#include <cstring>
#include <set>
#include <map>
#include <fstream>
#include <string>
#include <stack>
#include <deque>
#include <algorithm>
#include <random>
#include <ctime>
#include <sstream>
#include <functional>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> intpair;
typedef pair<ll, ll> llpair;
typedef long double ld;

int N, M, K;
string S;

vector<int> L[26];
set<int> answ;
string anss = "";

void insert(int index)
{
	if (!L[index].size())
		return;

	for (int pos : L[index])
	{
		auto upp = answ.upper_bound(pos);
		upp--;
		auto low = upp;
		upp++;

		if (*upp - *low > M)
		{
			answ.insert(pos);
			anss += 'a' + index;
		}
	}

	auto iter = answ.begin();
	auto last = iter;
	iter++;
	for (; iter != answ.end(); ++iter)
	{
		if (*iter - *last > M)
			return;
		last = iter;
	}

	cout << anss << endl;
	exit(0);
}

int main()
{
	ios_base::sync_with_stdio(0);

	cin >> M;
	cin >> S;
	N = S.length();

	answ.insert(0);
	answ.insert(N + 1);

	int i = 1;
	for (char c : S)
		L[c - 'a'].push_back(i++);

	for (int i = 0; i < 26; ++i)
		insert(i);

	return 0;
}


#include <iostream>
#include <vector>
#include <queue>
#include <cmath>
#include <cstring>
#include <set>
#include <map>
#include <fstream>
#include <string>
#include <stack>
#include <deque>
#include <algorithm>
#include <random>
#include <ctime>
#include <sstream>
#include <functional>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> intpair;
typedef pair<ll, ll> llpair;
typedef long double ld;

int N, M, K;
string S;

int main()
{
	ios_base::sync_with_stdio(0);

	cin >> M >> S;
	N = S.length();

	vector<pair<char, int>> A(N);

	for (int i = 0; i < N; ++i)
		A[i] = { S[i], i };

	sort(A.begin(), A.end());
	set<int> ans;

	char lastC;
	int ptr = 0;

	while (true)
	{
		lastC = A[ptr].first;
		while (ptr < N && lastC == A[ptr].first)
		{
			ans.insert(A[ptr].second);
			lastC = A[ptr].first;
			ptr++;
		}
		bool er = true;
		while (ans.size() > 1 && er)
		{
			er = false;
			auto v1 = ans.begin();
			v1++;
			if (*v1 < M)
			{
				v1--;
				if (S[*v1] == lastC)
					ans.erase(v1);
				er = true;
			}
		}

		er = true;
		while (ans.size() > 1 && er)
		{
			er = false;
			auto v2 = ans.end();
			v2--;
			v2--;
			if (*v2 >= (N - M))
			{
				v2++;
				if (S[*v2] == lastC)
					ans.erase(v2);
				er = true;
			}
		}

		auto v = ans.begin();
		v++;
		for (; ; ++v)
		{
			v--;
			int prv = *v;
			v++;
			if (v == ans.end())
				break;
			v++;
			if (v == ans.end())
				break;
			int nxt = *v;
			v--;

			if (nxt - prv <= M && S[*v] == lastC)
			{
				v = ans.erase(v);
				v--;
			}
		}

		if (*ans.begin() >= M || *ans.rbegin() < (N - M))
			continue;

		v = ans.begin();
		v++;
		bool done = true;
		for (; ; ++v)
		{
			v--;
			int prv = *v;
			v++;
			if (v == ans.end())
				break;
			int cur = *v;
			if (cur - prv > M)
			{
				done = false;
				break;
			}
		}
		if (done)
		{
			string s = "";
			for (int i : ans)
				s += S[i];
			sort(s.begin(), s.end());
			cout << s << endl;
			return 0;
		}
	}

	return 0;
}