#include <bits/stdc++.h>
#define mp make_pair
#define ii pair<int,int>

using namespace std;
struct data
{
    int x,y,cost,dir;
    data(){}
    data(int _x , int _y , int _cost , int _dir) : x(_x) , y(_y) , cost(_cost) , dir(_dir){}
};
char grid[1002][1002];
int  n,m,sx,sy,dist[1001][1001],gx,gy;
ii mv[4]={mp(1,0),mp(0,1),mp(0,-1),mp(-1,0)};
bool check(int,int),BFS(int,int);

int main()
{
    scanf("%d%d",&n,&m);
    for(int i=0;i<n;i++)
        scanf("%s",grid[i]);
    for(int i=0;i<n;i++)
        for(int j=0;j<m;j++)
        {
            dist[i][j]=10;
            if(grid[i][j]=='S')
                sx=i , sy=j;
            if(grid[i][j]=='T')
                gx=i , gy=j;
        }
    bool res=BFS(sx,sy);
    if(res)
        cout<<"YES";
    else
        cout<<"NO";
}
bool BFS(int x , int y)
{
    dist[x][y]=0;
    deque<data> q;
    for(int k=0;k<4;k++)
    {
        int i=x+mv[k].first , j=y+mv[k].second;
        if(check(i,j))
            q.push_back(data(i,j,0,k));
    }
    while(!q.empty())
    {
        data curr=q.front();
        q.pop_front();
        int i=curr.x , j=curr.y , c=curr.cost , d=curr.dir;
        if(i==gx && j==gy)
            return true;
        if(c<dist[i][j] && c<=2)
        {
            for(int k=0;k<4;k++)
            {
                int nxt_x=i+mv[k].first,nxt_y=j+mv[k].second,nxt_c=c+(k!=d),nxt_dir=k;
                if(check(nxt_x,nxt_y))
                {
                    if(nxt_c<dist[nxt_x][nxt_y] && nxt_c<=2)
                    {
                        if(nxt_x==gx && nxt_y==gy)
                            return true;
                        if(k==d)
                        {
                            q.push_front(data(nxt_x,nxt_y,nxt_c,nxt_dir));
                            continue;
                        }
                        else
                            q.push_back(data(nxt_x,nxt_y,nxt_c,nxt_dir));
                    }
                }
            }
        }
    }
    return false;
}
bool check(int x , int y)
{
    return (x<n && x>=0 && y<m && y>=0 && grid[x][y]!='*');
}


#include <bits/stdc++.h>
#define mp make_pair
#define ii pair<int,int>

using namespace std;
struct data
{
    int x,y,cost,dir;
    data(){}
    data(int _x , int _y , int _cost , int _dir) : x(_x) , y(_y) , cost(_cost) , dir(_dir){}
};
char grid[1002][1002];
int  n,m,sx,sy,dist[1001][1001],gx,gy;
ii mv[4]={mp(1,0),mp(0,1),mp(0,-1),mp(-1,0)};
bool check(int,int),BFS(int,int);

int main()
{
    scanf("%d%d",&n,&m);
    for(int i=0;i<n;i++)
        scanf("%s",grid[i]);
    for(int i=0;i<n;i++)
        for(int j=0;j<m;j++)
        {
            dist[i][j]=10;
            if(grid[i][j]=='S')
                sx=i , sy=j;
            if(grid[i][j]=='T')
                gx=i , gy=j;
        }
    bool res=BFS(sx,sy);
    if(res)
        cout<<"YES";
    else
        cout<<"NO";
}
bool BFS(int x , int y)
{
    dist[x][y]=0;
    queue<data> q;
    for(int k=0;k<4;k++)
    {
        int i=x+mv[k].first , j=y+mv[k].second;
        if(check(i,j))
            q.push(data(i,j,0,k));
    }
    while(!q.empty())
    {
        data curr=q.front();
        q.pop();
        int i=curr.x , j=curr.y , c=curr.cost , d=curr.dir;
        //cout<<i<<' '<<j<<' '<<c<<' '<<d<<endl;
        if(i==gx && j==gy)
            return true;
        if(c<=2)
        {
            if(c<dist[i][j])
                dist[i][j]=c;
            for(int k=0;k<4;k++)
            {
                int nxt_x=i+mv[k].first,nxt_y=j+mv[k].second,nxt_c=c+(k!=d),nxt_dir=k;
                if(check(nxt_x,nxt_y))
                {
                    if(nxt_c<3)
                    {
                        if(nxt_x==gx && nxt_y==gy)
                            return true;
                        if(nxt_c<=2)
                            q.push(data(nxt_x,nxt_y,nxt_c,nxt_dir));
                    }
                }
            }
        }
    }
    return false;
}
bool check(int x , int y)
{
    return (x<n && x>=0 && y<m && y>=0 && grid[x][y]!='*');
}


#include <bits/stdc++.h>
#define mp make_pair
#define ii pair<int,int>

using namespace std;
struct data
{
    int x,y,cost,dir;
    data(){}
    data(int _x , int _y , int _cost , int _dir) : x(_x) , y(_y) , cost(_cost) , dir(_dir){}
};
char grid[1002][1002];
int  n,m,sx,sy,dist[1001][1001],gx,gy;
ii mv[4]={mp(1,0),mp(0,1),mp(0,-1),mp(-1,0)};
bool check(int,int),BFS(int,int);

int main()
{
    scanf("%d%d",&n,&m);
    for(int i=0;i<n;i++)
        scanf("%s",grid[i]);
    for(int i=0;i<n;i++)
        for(int j=0;j<m;j++)
        {
            dist[i][j]=10;
            if(grid[i][j]=='S')
                sx=i , sy=j;
            if(grid[i][j]=='T')
                gx=i , gy=j;
        }
    bool res=BFS(sx,sy);
    if(res)
        cout<<"YES";
    else
        cout<<"NO";
}
bool BFS(int x , int y)
{
    dist[x][y]=0;
    queue<data> q;
    for(int k=0;k<4;k++)
    {
        int i=x+mv[k].first , j=y+mv[k].second;
        if(check(i,j))
            q.push(data(i,j,0,k));
    }
    while(!q.empty())
    {
        data curr=q.front();
        q.pop();
        int i=curr.x , j=curr.y , c=curr.cost , d=curr.dir;
        //cout<<i<<' '<<j<<' '<<c<<' '<<d<<endl;
        if(i==gx && j==gy)
            return true;
        if(c<=dist[i][j])
        {
            for(int k=0;k<4;k++)
            {
                int nxt_x=i+mv[k].first,nxt_y=j+mv[k].second,nxt_c=c+(k!=d),nxt_dir=k;
                if(check(nxt_x,nxt_y))
                {
                    if(nxt_c<=2)
                    {
                        if(nxt_x==gx && nxt_y==gy)
                            return true;
                        q.push(data(nxt_x,nxt_y,nxt_c,nxt_dir));
                    }
                }
            }
        }
    }
    return false;
}
bool check(int x , int y)
{
    return (x<n && x>=0 && y<m && y>=0 && grid[x][y]!='*');
}


#include <bits/stdc++.h>
#define mp make_pair
#define ii pair<int,int>

using namespace std;
struct data
{
    int x,y,cost,dir;
    data(){}
    data(int _x , int _y , int _cost , int _dir) : x(_x) , y(_y) , cost(_cost) , dir(_dir){}
};
char grid[1002][1002];
int  n,m,sx,sy,dist[1001][1001],gx,gy;
ii mv[4]={mp(1,0),mp(0,1),mp(0,-1),mp(-1,0)};
bool check(int,int),BFS(int,int);

int main()
{
    scanf("%d%d",&n,&m);
    for(int i=0;i<n;i++)
        scanf("%s",grid[i]);
    for(int i=0;i<n;i++)
        for(int j=0;j<m;j++)
        {
            dist[i][j]=10;
            if(grid[i][j]=='S')
                sx=i , sy=j;
            if(grid[i][j]=='T')
                gx=i , gy=j;
        }
    bool res=BFS(sx,sy);
    if(res)
        cout<<"YES";
    else
        cout<<"NO";
}
bool BFS(int x , int y)
{
    dist[x][y]=0;
    deque<data> q;
    for(int k=0;k<4;k++)
    {
        int i=x+mv[k].first , j=y+mv[k].second;
        if(check(i,j))
            q.push_back(data(i,j,0,k));
    }
    while(!q.empty())
    {
        data curr=q.front();
        q.pop_front();
        int i=curr.x , j=curr.y , c=curr.cost , d=curr.dir;
        if(i==gx && j==gy)
            return true;
        if(c<dist[i][j] && c<=2)
        {
            for(int k=0;k<4;k++)
            {
                int nxt_x=i+mv[k].first,nxt_y=j+mv[k].second,nxt_c=c+(k!=d),nxt_dir=k;
                if(check(nxt_x,nxt_y))
                {
                    if(nxt_c<dist[nxt_x][nxt_y] && nxt_c<=2)
                    {
                        if(nxt_x==gx && nxt_y==gy)
                            return true;
                        if(nxt_x==gx || nxt_y==gy)
                            q.push_front(data(nxt_x,nxt_y,nxt_c,nxt_dir));
                        else
                            q.push_back(data(nxt_x,nxt_y,nxt_c,nxt_dir));
                    }
                }
            }
        }
    }
    return false;
}
bool check(int x , int y)
{
    return (x<n && x>=0 && y<m && y>=0 && grid[x][y]!='*');
}


#include <bits/stdc++.h>
#define mp make_pair
#define ii pair<int,int>

using namespace std;
struct data
{
    int x,y,cost,dir;
    data(){}
    data(int _x , int _y , int _cost , int _dir) : x(_x) , y(_y) , cost(_cost) , dir(_dir){}
};
char grid[1002][1002];
int  n,m,sx,sy,dist[1001][1001],gx,gy;
ii mv[4]={mp(1,0),mp(0,1),mp(0,-1),mp(-1,0)};
bool check(int,int),BFS(int,int);

int main()
{
    scanf("%d%d",&n,&m);
    for(int i=0;i<n;i++)
        scanf("%s",grid[i]);
    for(int i=0;i<n;i++)
        for(int j=0;j<m;j++)
        {
            dist[i][j]=1000;
            if(grid[i][j]=='S')
                sx=i , sy=j;
            else if(grid[i][j]=='T')
                gx=i , gy=j;
        }
    bool res=BFS(sx,sy);
    if(res)
        cout<<"YES";
    else
        cout<<"NO";
}
bool BFS(int x , int y)
{
    dist[x][y]=0;
    deque<data> q;
    for(int k=0;k<4;k++)
    {
        int i=x+mv[k].first , j=y+mv[k].second;
        if(check(i,j))
        {
            dist[i][j]=0;
            q.push_back(data(i,j,0,k));
        }
    }
    while(!q.empty())
    {
        data curr=q.front();
        q.pop_front();
        int i=curr.x , j=curr.y , c=curr.cost , d=curr.dir;
        if(i==gx && j==gy)
            return true;
        if(c<=dist[i][j] && c<=2)
        {
            for(int k=0;k<4;k++)
            {
                int nxt_x=i+mv[k].first,nxt_y=j+mv[k].second,nxt_c=c+(k!=d),nxt_dir=k;
                if(check(nxt_x,nxt_y))
                {
                    if(nxt_c<=dist[nxt_x][nxt_y] && nxt_c<=2)
                    {
                        if(nxt_x==gx && nxt_y==gy)
                            return true;
                        dist[nxt_x][nxt_y]=nxt_c;
                        if(k==d)
                            q.push_front(data(nxt_x,nxt_y,nxt_c,nxt_dir));
                        else
                            q.push_back(data(nxt_x,nxt_y,nxt_c,nxt_dir));
                    }
                }
            }
        }
    }
    return false;
}
bool check(int x , int y)
{
    return (x<n && x>=0 && y<m && y>=0 && grid[x][y]!='*');
}


#include <bits/stdc++.h>
#define mp make_pair
#define ii pair<int,int>

using namespace std;
struct data
{
    int x,y,cost,dir;
    data(){}
    data(int _x , int _y , int _cost , int _dir) : x(_x) , y(_y) , cost(_cost) , dir(_dir){}
};
char grid[1001][1001];
int  n,m,sx=-1,sy=-1,dist[1001][1001] , gx,gy;
ii mv[4]={mp(1,0),mp(0,1),mp(0,-1),mp(-1,0)};
bool check(int,int),BFS(int,int);

int main()
{
    scanf("%d%d",&n,&m);
    for(int i=0;i<n;i++)
        scanf("%s",grid[i]);
    for(int i=0;i<n;i++)
        for(int j=0;j<m;j++)
        {
            dist[i][j]=1e8;
            if(grid[i][j]=='S')
                sx=i , sy=j;
            if(grid[i][j]=='T')
                gx=i , gy=j;
        }
    bool res=BFS(sx,sy);
    if(res)
        cout<<"YES";
    else
        cout<<"NO";
}
bool BFS(int x , int y)
{
    dist[x][y]=0;
    queue<data> q;
    for(int k=0;k<4;k++)
    {
        int i=x+mv[k].first , j=y+mv[k].second;
        if(check(i,j))
            q.push(data(i,j,0,k));
    }
    while(!q.empty())
    {
        data curr=q.front();
        q.pop();
        int i=curr.x , j=curr.y , c=curr.cost , d=curr.dir;
        if(dist[i][j]>c)
        {
            dist[i][j]=c;
            for(int k=0;k<4;k++)
            {
                int nxt_x=i+mv[k].first,nxt_y=j+mv[k].second,nxt_c=c+(k!=d),nxt_dir=k;
                if(check(nxt_x,nxt_y))
                {
                    if(nxt_c<3)
                    {
                        if(nxt_x==gx && nxt_y==gy)
                            return true;
                        q.push(data(nxt_x,nxt_y,nxt_c,nxt_dir));
                    }
                }
            }
        }
    }
    return false;
}
bool check(int x , int y)
{
    return (x<n && x>=0 && y<m && y>=0 && grid[x][y]!='*');
}


#include <bits/stdc++.h>
#define mp make_pair
#define ii pair<int,int>

using namespace std;
struct data
{
    int x,y,cost,dir;
    data(){}
    data(int _x , int _y , int _cost , int _dir) : x(_x) , y(_y) , cost(_cost) , dir(_dir){}
};
char grid[1002][1002];
int  n,m,sx,sy,dist[1001][1001],gx,gy;
ii mv[4]={mp(1,0),mp(0,1),mp(0,-1),mp(-1,0)};
bool check(int,int),BFS(int,int);

int main()
{
    scanf("%d%d",&n,&m);
    for(int i=0;i<n;i++)
        scanf("%s",grid[i]);
    for(int i=0;i<n;i++)
        for(int j=0;j<m;j++)
        {
            dist[i][j]=10;
            if(grid[i][j]=='S')
                sx=i , sy=j;
            if(grid[i][j]=='T')
                gx=i , gy=j;
        }
    bool res=BFS(sx,sy);
    if(res)
        cout<<"YES";
    else
        cout<<"NO";
}
bool BFS(int x , int y)
{
    dist[x][y]=0;
    queue<data> q;
    for(int k=0;k<4;k++)
    {
        int i=x+mv[k].first , j=y+mv[k].second;
        if(check(i,j))
            q.push(data(i,j,0,k));
    }
    while(!q.empty())
    {
        data curr=q.front();
        q.pop();
        int i=curr.x , j=curr.y , c=curr.cost , d=curr.dir;
        if(i==gx && j==gy)
            return true;
        if(c<dist[i][j] && c<=2)
        {
            for(int k=0;k<4;k++)
            {
                int nxt_x=i+mv[k].first,nxt_y=j+mv[k].second,nxt_c=c+(k!=d),nxt_dir=k;
                if(check(nxt_x,nxt_y))
                {
                    if(nxt_c<dist[nxt_x][nxt_y] && nxt_c<=2)
                    {
                        if(nxt_x==gx && nxt_y==gy)
                            return true;
                        q.push(data(nxt_x,nxt_y,nxt_c,nxt_dir));
                    }
                }
            }
        }
    }
    return false;
}
bool check(int x , int y)
{
    return (x<n && x>=0 && y<m && y>=0 && grid[x][y]!='*');
}


#include<bits/stdc++.h>
using namespace std;
int n,m,s;
int check_x[5]={0,0,0,1,-1},check_y[5]={0,1,-1,0,0};
bool home_(int i,int j,pair<int,int> home)
{
	return (home.first==i&&home.second==j);
}
int main(){
	cin>>n>>m;
	char ma[n+1][m+1];
	bool used[n+2][m+2];
	int cost[n+2][m+2];
	pair<int,int>home,bank;
	for(int i=1;i<=n;i++)
		for(int j=1;j<=m;j++)
		{
			if(ma[i][j]=='S')
			{
				home.first=i;
				home.second=j;
			}
			if(ma[i][j]=='T')
			{
				bank.first=i;
				bank.second=j;
		 	}
       	}
	memset(cost,-1,sizeof(cost));
	cost[home.first][home.second]=0;
	memset(used,false,sizeof(used));
	for(int i=1;i<=n;i++)
		for(int j=1;j<=m;j++)
		{
			cin>>ma[i][j];
			used[i][j]=false;
			if(ma[i][j]=='*')
			{
				used[i][j]=true;
				cost[i][j]=-100;
				s++;
			}
		}
	for(int i=0;i<=n+1;i++)
	{
    		used[i][0]=true;
         		used[i][m+1]=true;
		cost[i][0]=-100;
		cost[i][m+1]=-100;
	}
  	for(int i=0;i<=m+1;i++)
  	{
    	used[0][i]=true;
        used[n+1][i]=true;
		cost[0][i]=-100;
		cost[n+1][i]=-100;
	}
	s++;
	while(s!=n*m)
		for(int i=1;i<=n;i++)
			for(int j=1;j<=m;j++)
    			{
				if(cost[i][j]==-1)
				{
					int k;
					bool check=false;
					for(k=1;k<=4;k++)             //右 左 下 上
			 		{
						check=(cost[i+check_x[k]][j+check_y[k]]!=-1&&cost[i+check_x[k]][j+check_y[k]]!=-100);
						if(check)
						{
							break;
							s++;
						}
					}
					if(check)
					{
						ma[i+check_x[k][j+check_y[k]];

					}
				}
			}
	ans=cost[bank.first][bank.second];
	if(ans<=2)
		cout<<"YES";
	else
		cout<<"NO";
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
int n,m,s;
int check_x[5]={0,0,0,1,-1},check_y[5]={0,1,-1,0,0};
bool home_(int i,int j,pair<int,int> home)
{
	return (home.first==i&&home.second==j);
}
int main(){
	cin>>n>>m;
	char ma[n+1][m+1];
	bool used[n+2][m+2];
	int cost[n+2][m+2];
	pair<int,int>home,bank;
	for(int i=1;i<=n;i++)
		for(int j=1;j<=m;j++)
		{
			if(ma[i][j]=='S')
			{
				home.first=i;
				home.second=j;
			}
			if(ma[i][j]=='T')
			{
				bank.first=i;
				bank.second=j;
		 	}
       	}
	memset(cost,-1,sizeof(cost));
	cost[home.first][home.second]=0;
	memset(used,false,sizeof(used));
	for(int i=1;i<=n;i++)
		for(int j=1;j<=m;j++)
		{
			cin>>ma[i][j];
			used[i][j]=false;
			if(ma[i][j]=='*')
			{
				used[i][j]=true;
				cost[i][j]=-100;
				s++;
			}
		}
	for(int i=0;i<=n+1;i++)
	{
    		used[i][0]=true;
         		used[i][m+1]=true;
		cost[i][0]=-100;
		cost[i][m+1]=-100;
	}
  	for(int i=0;i<=m+1;i++)
  	{
    	used[0][i]=true;
        used[n+1][i]=true;
		cost[0][i]=-100;
		cost[n+1][i]=-100;
	}
	int ans=0;S
	s++;
	while(s!=n*m)
		for(int i=1;i<=n;i++)
			for(int j=1;j<=m;j++)
    			{
				if(cost[i][j]==-1)
				{
					int k;
					bool check=false;
					for(k=1;k<=4;k++)             //右 左 下 上
			 		{
						check=(cost[i+check_x[k]][j+check_y[k]]!=-1&&cost[i+check_x[k]][j+check_y[k]]!=-100);
						if(check)
						{
							break;
							s++;
						}
					}
					if(check)
					{
						if()
						{
							ans++;
						}
					}
				}
			}
	ans=cost[bank.first][bank.second];
	if(ans<=2)
		cout<<"YES";
	else
		cout<<"NO";
	return 0;
}


#include<iostream>
using namespace std;
int main(){
    int n,m;
    cin>>n>>m;
    string x;
    cin>>x;
    cin>>x;
    cin>>x;
    cin>>x;
    if(x=="****.")
        cout<<"YES";
    else if(x==".****")
        cout<<"NO";

}


#include <bits/stdc++.h>
using namespace std;
int n,m;
char a[1010][1010];
bool mark[1010][1010][4][3];
int dx[4]={0,1,0,-1};
int dy[4]={1,0,-1,0};
bool bfs(int i,int j,int d,int turn)
{
	if(i==n||j==m||i<0||j<0||turn>2||mark[i][j][d][turn]||a[i][j]=='*')
		return 0;
	if(a[i][j]=='T')
		return 1;
	mark[i][j][d][turn]=1;
	bool ans=0;
	for(int k=0;k<4;k++)
		ans=(ans||bfs(i+dx[k],j+dy[k],k,turn+((k==d||d==-1)?0:1)));
	return ans;
}
int main(){
	cin>>n>>m;
	int x,y;
	for(int i=0;i<n;i++)
		for (int j=0;j<m;j++)
		{
			cin>>a[i][j];
			if(a[i][j]=='S')
			{
				x=i;
				y=j;
			}
		}
	if(bfs(x,y,-1,0))
		cout<<"YES";
	else
		cout<<"NO";
}


#include<bits/stdc++.h>
using namespace std;
int n,m,s;
int check_x[5]={0,0,0,1,-1},check_y[5]={0,1,-1,0,0};
bool home_(int i,int j,pair<int,int> home)
{
	return (home.first==i&&home.second==j);
}
int main(){
	cin>>n>>m;
	char map[n+1][m+1];
	bool used[n+2][m+2];
	int cost[n+2][m+2];
	pair<int,int>home,bank;
	for(int i=1;i<=n;i++)
		for(int j=1;j<=m;j++)
		{
			if(map[i][j]=='S')
			{
				home.first=i;
				home.second=j;
			}
			if(map[i][j]=='T')
			{
				bank.first=i;
				bank.second=j;
		 	}
       	}
	memset(cost,-1,sizeof(cost));
	cost[home.first][home.second]=0;
	memset(used,false,sizeof(used));
	for(int i=1;i<=n;i++)
		for(int j=1;j<=m;j++)
		{
			cin>>map[i][j];
			used[i][j]=false;
			if(map[i][j]=='*')
			{
				used[i][j]=true;
				cost[i][j]=-100;
				s++;
			}
		}
	for(int i=0;i<=n+1;i++)
	{
    		used[i][0]=true;
         		used[i][m+1]=true;
		cost[i][0]=-100;
		cost[i][m+1]=-100;
	}
  	for(int i=0;i<=m+1;i++)
  	{
    	used[0][i]=true;
        used[n+1][i]=true;
		cost[0][i]=-100;
		cost[n+1][i]=-100;
	}
	s++;
	int ans=0;
	while(s!=n*m)
		for(int i=1;i<=n;i++)
			for(int j=1;j<=m;j++)
    			{
				if(cost[i][j]==-1)
				{
					int k;
					bool check=false;
					for(k=1;k<=4;k++)             //右 左 下 上
			 		{
						check=(cost[i+check_x[k]][j+check_y[k]]!=-1&&cost[i+check_x[k]][j+check_y[k]]!=-100);
						if(check)
						{
							break;
							s++;
						}
					}
					if(check)
					{
						map[i+check_x[k][j+check_y[k]];

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


#include <bits/stdc++.h>
using namespace std;
int n,m;
char a[1010][1010];
bool mark[1010][1010][4][3];
int dx[4]={0,1,0,-1};
int dy[4]={1,0,-1,0};
bool bfs(int i,int j,int d,int turn)
{
	if(i==n||j==m||i<0||j<0||turn>2||mark[i][j][d][turn]||a[i][j]=='*')
		return 0;
	if(a[i][j]=='T')
		return 1;
	mark[i][j][d][turn]=1;
	bool ans=0;
	for(int k=0;k<4;k++)
	{
		int a;
		if(k==d||d==-1)
			a=0;
		else
			a=1;
		int ii=i+dx[k],jj=j+dy[k];
		ans=(ans||bfs(ii,jj,k,turn+a));
	}
	return ans;
}
int main(){
	cin>>n>>m;
	int x,y;
	for(int i=0;i<n;i++)
		for (int j=0;j<m;j++)
		{
			cin>>a[i][j];
			if(a[i][j]=='S')
			{
				x=i;
				y=j;
			}
		}
	if(bfs(x,y,-1,0))
		cout<<"YES";
	else
		cout<<"NO";
	return 0;
}


// #pragma GCC optimize("Ofast")
// #pragma GCC target("avx2,bmi,bmi2,lzcnt")
// #define NDEBUG

#include <bits/extc++.h>
#include <x86intrin.h>

struct rep {
  struct iter {
    int i;
    constexpr void operator++() { ++i; }
    constexpr int operator*() const { return i; }
    friend constexpr bool operator!=(iter a, iter b) { return *a != *b; }
  };
  const int l, r;
  constexpr rep(int _l, int _r) : l(std::min(_l, _r)), r(_r) {}
  constexpr rep(int n) : rep(0, n) {}
  constexpr iter begin() const { return {l}; }
  constexpr iter end() const { return {r}; }
};
struct per {
  struct iter {
    int i;
    constexpr void operator++() { --i; }
    constexpr int operator*() const { return i; }
    friend constexpr bool operator!=(iter a, iter b) { return *a != *b; }
  };
  const int l, r;
  constexpr per(int _l, int _r) : l(std::min(_l, _r)), r(_r) {}
  constexpr per(int n) : per(0, n) {}
  constexpr iter begin() const { return {r - 1}; }
  constexpr iter end() const { return {l - 1}; }
};
template <class C>
constexpr int isize(C&& c) {
  using std::size;
  return size(std::forward<C>(c));
}
template <class T, class U>
constexpr bool chmin(T& a, U&& b) {
  return b < a ? a = std::forward<U>(b), true : false;
}
template <class T, class U>
constexpr bool chmax(T& a, U&& b) {
  return a < b ? a = std::forward<U>(b), true : false;
}

int main() {
  using namespace std;
  cin.tie(nullptr)->sync_with_stdio(false);
  cout << fixed << setprecision(20);

  using num = long double;
  constexpr num eps = 1e-10, inf = 1e10;

  auto f = [&](num l, num r, num s, num v) -> pair<num, num> {
    if (v > eps) {
      return {max((l - s) / v, num{}), max((r - s) / v, num{})};
    } else if (v < -eps) {
      return {max((r - s) / v, num{}), max((l - s) / v, num{})};
    } else {
      if (l + eps < s and s < r - eps) return {0, inf};
      return {0, 0};
    }
  };

  int n;
  cin >> n;
  num lx, ly, rx, ry;
  cin >> lx >> ly >> rx >> ry;
  vector<pair<num, num>> v;
  while (n--) {
    num x, y, vx, vy;
    cin >> x >> y >> vx >> vy;
    v.push_back(f(lx, rx, x, vx));
    v.push_back(f(ly, ry, y, vy));
  }
  num a = 0, b = inf;
  for (auto&& [l, r] : v) {
    chmax(a, l);
    chmin(b, r);
  }
  if (b - a < eps)
    cout << "-1\n";
  else
    cout << a << '\n';
}


#include <bits/stdc++.h>

using namespace std;

void Draganov47(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cout << fixed << setprecision(10);
}

struct pt {
    double x, y;
};

struct vc {
    double x, y;
};

vc gv(pt a, pt b) {
    return {b.x - a.x, b.y - a.y};
}

double ks(vc a, vc b) {
    return (a.x * b.y) - (a.y * b.x);
}

double sc(vc a, vc b) {
    return (a.x + b.x) - (a.y + b.y);
}

const int MAX = 1e5 + 47;

struct mause{
    pt a, b, speed;
};

int n;

pt f, s;

mause a[MAX];

void valid(mause a){
    a.b.x = a.a.x + a.speed.x * 0.001;
    a.b.y = a.a.y + a.speed.y * 0.001;
    bool f11, f22, f33, f44;
    pt f1, s1;
    f1.x = f.x;
    f1.y = s.y;
    s1.x = s.x;
    s1.y = f.y;
    f11 = (ks(gv(a.a, a.b), gv(f, f1)) == 0 && (ks(gv(f, a.a), gv(f, f1)) == 0 || ks(gv(f, a.b), gv(f, f1)) == 0));
    f22 = (ks(gv(a.a, a.b), gv(s, f1)) == 0 && (ks(gv(s, a.a), gv(s, f1)) == 0 || ks(gv(s, a.b), gv(s, f1)) == 0));
    f33 = (ks(gv(a.a, a.b), gv(s1, f)) == 0 && (ks(gv(s1, a.a), gv(s1, f)) == 0 || ks(gv(s1, a.b), gv(s1, f)) == 0));
    f44 = (ks(gv(a.a, a.b), gv(s1, s)) == 0 && (ks(gv(s1, a.a), gv(s1, s)) == 0 || ks(gv(s1, a.b), gv(s1, s)) == 0));
    if (f11 || f22 || f33 || f44){
        cout << -1;
        exit(0);
    }
}

int main(){
    Draganov47();

    cin >> n;

    cin >> f.x >> f.y >> s.x >> s.y;

    double maxX = max(f.x, s.x);
    double minX = min(f.x, s.x);
    double maxY = max(f.y, s.y);
    double minY = min(f.y, s.y);

    vector < pair <double, int> > sl;

    for (int i = 1; i <= n; i++) cin >> a[i].a.x >> a[i].a.y >> a[i].speed.x >> a[i].speed.y, valid(a[i]);
    for (int i = 1; i <= n; i++){

        double min_x = -1, max_x = -1;

        //

        double l = 0, r = 1e6;

        for (int z = 1; z <= 100; z++){
            double m = (l + r) / 2.0;
            if (a[i].speed.x > 0){
                if (m * a[i].speed.x + a[i].a.x <= minX) l = m;
                else r = m;
            }
            else {
                if (m * a[i].speed.x + a[i].a.x <= minX) r = m;
                else l = m;
            }
        }

        min_x = l;

        l = 0, r = 1e6;

        for (int z = 1; z <= 100; z++){
            double m = (l + r) / 2.0;
            if (a[i].speed.x > 0){
                if (m * a[i].speed.x + a[i].a.x <= maxX) l = m;
                else r = m;
            }
            else {
                if (m * a[i].speed.x + a[i].a.x <= maxX) r = m;
                else l = m;
            }
        }

        max_x = l;

        double min_y = -1, max_y = -1;

        l = 0, r = 1e6;

        for (int z = 1; z <= 100; z++){
            double m = (l + r) / 2.0;
            if (a[i].speed.y > 0){
                if (m * a[i].speed.y + a[i].a.y <= minY) l = m;
                else r = m;
            }
            else {
                if (m * a[i].speed.y + a[i].a.y <= minY) r = m;
                else l = m;
            }
        }

        min_y = l;

        l = 0, r = 1e6;

        for (int z = 1; z <= 100; z++){
            double m = (l + r) / 2.0;
            if (a[i].speed.y > 0){
                if (m * a[i].speed.y + a[i].a.y <= maxY) l = m;
                else r = m;
            }
            else {
                if (m * a[i].speed.y + a[i].a.y <= maxY) r = m;
                else l = m;
            }
        }

        max_y = l;

        //

        if (max_y < min_y) swap(max_y, min_y);

        if (max_x < min_x) swap(max_x, min_x);

        double min_time = max(min_x, min_y);
        double max_time = min(max_x, max_y);

        if (min_time > max_time + 0.00001){
            cout << -1;
            return 0;
        }

        sl.push_back({min_time, 1});
        sl.push_back({max_time + 0.00001, -1});
    }

    int status = 0;

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

    for (int i = 0; i < sl.size(); i++){
        status += sl[i].second;
        if (status == n){
            cout << sl[i].first;
            return 0;
        }
    }

    cout << -1;
}


#include <bits/stdc++.h>

using namespace std;

void Draganov47(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cout << fixed << setprecision(10);
}

struct pt {
    double x, y;
};

struct vc {
    double x, y;
};

vc gv(pt a, pt b) {
    return {b.x - a.x, b.y - a.y};
}

double ks(vc a, vc b) {
    return (a.x * b.y) - (a.y * b.x);
}

double sc(vc a, vc b) {
    return (a.x + b.x) - (a.y + b.y);
}

const int MAX = 1e5 + 47;

struct mause{
    pt a, b, speed;
};

int n;

const double e = 0.000001;

pt f, s;

mause a[MAX];

int main(){
    Draganov47();

    cin >> n;

    cin >> f.x >> f.y >> s.x >> s.y;

    double maxX = max(f.x, s.x);
    double minX = min(f.x, s.x);
    double maxY = max(f.y, s.y);
    double minY = min(f.y, s.y);

    vector < pair <double, int> > sl;

    for (int i = 1; i <= n; i++) cin >> a[i].a.x >> a[i].a.y >> a[i].speed.x >> a[i].speed.y;
    for (int i = 1; i <= n; i++){

        double min_x = -1, max_x = -1;

        //

        double l = 0, r = 1e6;

        for (int z = 1; z <= 100; z++){
            double m = (l + r) / 2.0;
            if (a[i].speed.x > 0){
                if (m * a[i].speed.x + a[i].a.x <= minX) l = m;
                else r = m;
            }
            else {
                if (m * a[i].speed.x + a[i].a.x <= minX) r = m;
                else l = m;
            }
        }

        min_x = l;

        l = 0, r = 1e6;

        for (int z = 1; z <= 100; z++){
            double m = (l + r) / 2.0;
            if (a[i].speed.x > 0){
                if (m * a[i].speed.x + a[i].a.x <= maxX) l = m;
                else r = m;
            }
            else {
                if (m * a[i].speed.x + a[i].a.x <= maxX) r = m;
                else l = m;
            }
        }

        max_x = l;

        double min_y = -1, max_y = -1;

        l = 0, r = 1e6;

        for (int z = 1; z <= 100; z++){
            double m = (l + r) / 2.0;
            if (a[i].speed.y > 0){
                if (m * a[i].speed.y + a[i].a.y <= minY) l = m;
                else r = m;
            }
            else {
                if (m * a[i].speed.y + a[i].a.y <= minY) r = m;
                else l = m;
            }
        }

        min_y = l;

        l = 0, r = 1e6;

        for (int z = 1; z <= 100; z++){
            double m = (l + r) / 2.0;
            if (a[i].speed.y > 0){
                if (m * a[i].speed.y + a[i].a.y <= maxY) l = m;
                else r = m;
            }
            else {
                if (m * a[i].speed.y + a[i].a.y <= maxY) r = m;
                else l = m;
            }
        }

        max_y = l;

        //

        //cout << min_x << ' ' << max_x << "     " << min_y << ' ' << max_y << endl;

        if (max_y < min_y) swap(max_y, min_y);

        if (max_x < min_x) swap(max_x, min_x);

        double min_time = max(min_x, min_y);
        double max_time = min(max_x, max_y);

        if (min_time - e > max_time + e){
            cout << -1;
            return 0;
        }

        sl.push_back({min_time - e, 1});
        sl.push_back({max_time + e, -1});
    }

    int status = 0;

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

    for (int i = 0; i < sl.size(); i++){
        status += sl[i].second;
        if (status == n){
            cout << sl[i].first;
            return 0;
        }
    }

    cout << -1;
}


#include <bits/stdc++.h>

using namespace std;

void Draganov47(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cout << fixed << setprecision(10);
}

struct pt {
    double x, y;
};

struct vc {
    double x, y;
};

vc gv(pt a, pt b) {
    return {b.x - a.x, b.y - a.y};
}

double ks(vc a, vc b) {
    return (a.x * b.y) - (a.y * b.x);
}

double sc(vc a, vc b) {
    return (a.x + b.x) - (a.y + b.y);
}

const int MAX = 1e5 + 47;

struct mause{
    pt a, b, speed;
};

int n;

pt f, s;

mause a[MAX];

int main(){
    Draganov47();

    cin >> n;

    cin >> f.x >> f.y >> s.x >> s.y;

    double maxX = max(f.x, s.x);
    double minX = min(f.x, s.x);
    double maxY = max(f.y, s.y);
    double minY = min(f.y, s.y);

    vector < pair <double, int> > sl;

    for (int i = 1; i <= n; i++) cin >> a[i].a.x >> a[i].a.y >> a[i].speed.x >> a[i].speed.y;
    for (int i = 1; i <= n; i++){

        double min_x = -1, max_x = -1;

        //

        double l = 0, r = 1e6;

        for (int z = 1; z <= 100; z++){
            double m = (l + r) / 2.0;
            if (a[i].speed.x > 0){
                if (m * a[i].speed.x + a[i].a.x <= minX) l = m;
                else r = m;
            }
            else {
                if (m * a[i].speed.x + a[i].a.x <= minX) r = m;
                else l = m;
            }
        }

        min_x = l;

        l = 0, r = 1e6;

        for (int z = 1; z <= 100; z++){
            double m = (l + r) / 2.0;
            if (a[i].speed.x > 0){
                if (m * a[i].speed.x + a[i].a.x <= maxX) l = m;
                else r = m;
            }
            else {
                if (m * a[i].speed.x + a[i].a.x <= maxX) r = m;
                else l = m;
            }
        }

        max_x = l;

        double min_y = -1, max_y = -1;

        l = 0, r = 1e6;

        for (int z = 1; z <= 100; z++){
            double m = (l + r) / 2.0;
            if (a[i].speed.y > 0){
                if (m * a[i].speed.y + a[i].a.y <= minY) l = m;
                else r = m;
            }
            else {
                if (m * a[i].speed.y + a[i].a.y <= minY) r = m;
                else l = m;
            }
        }

        min_y = l;

        l = 0, r = 1e6;

        for (int z = 1; z <= 100; z++){
            double m = (l + r) / 2.0;
            if (a[i].speed.y > 0){
                if (m * a[i].speed.y + a[i].a.y <= maxY) l = m;
                else r = m;
            }
            else {
                if (m * a[i].speed.y + a[i].a.y <= maxY) r = m;
                else l = m;
            }
        }

        max_y = l;

        //

        //cout << min_x << ' ' << max_x << "     " << min_y << ' ' << max_y << endl;

        if (max_y < min_y) swap(max_y, min_y);

        if (max_x < min_x) swap(max_x, min_x);

        double min_time = max(min_x, min_y);
        double max_time = min(max_x, max_y);

        //cout << min_time << ' ' << max_time << endl;

        if (min_time + 0.000000000001 > max_time){
            cout << -1;
            return 0;
        }

        sl.push_back({min_time, 1});
        sl.push_back({max_time + 0.00000001, -1});
    }

    int status = 0;

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

    for (int i = 0; i < sl.size(); i++){
        status += sl[i].second;
        if (status == n){
            cout << sl[i].first;
            return 0;
        }
    }

    cout << -1;
}


#include <bits/stdc++.h>

using namespace std;

void Draganov47(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cout << fixed << setprecision(10);
}

struct pt {
    double x, y;
};

struct vc {
    double x, y;
};

vc gv(pt a, pt b) {
    return {b.x - a.x, b.y - a.y};
}

double ks(vc a, vc b) {
    return (a.x * b.y) - (a.y * b.x);
}

double sc(vc a, vc b) {
    return (a.x + b.x) - (a.y + b.y);
}

const int MAX = 1e5 + 47;

struct mause{
    pt a, b, speed;
};

int n;

pt f, s;

mause a[MAX];

int main(){
    Draganov47();

    cin >> n;

    cin >> f.x >> f.y >> s.x >> s.y;

    double maxX = max(f.x, s.x);
    double minX = min(f.x, s.x);
    double maxY = max(f.y, s.y);
    double minY = min(f.y, s.y);

    vector < pair <double, int> > sl;

    for (int i = 1; i <= n; i++) cin >> a[i].a.x >> a[i].a.y >> a[i].speed.x >> a[i].speed.y;
    for (int i = 1; i <= n; i++){

        double min_x = -1, max_x = -1;

        //

        double l = 0, r = 1e6;

        for (int z = 1; z <= 100; z++){
            double m = (l + r) / 2.0;
            if (a[i].speed.x > 0){
                if (m * a[i].speed.x + a[i].a.x <= minX) l = m;
                else r = m;
            }
            else {
                if (m * a[i].speed.x + a[i].a.x <= minX) r = m;
                else l = m;
            }
        }

        min_x = l;

        l = 0, r = 1e6;

        for (int z = 1; z <= 100; z++){
            double m = (l + r) / 2.0;
            if (a[i].speed.x > 0){
                if (m * a[i].speed.x + a[i].a.x <= maxX) l = m;
                else r = m;
            }
            else {
                if (m * a[i].speed.x + a[i].a.x <= maxX) r = m;
                else l = m;
            }
        }

        max_x = l;

        double min_y = -1, max_y = -1;

        l = 0, r = 1e6;

        for (int z = 1; z <= 100; z++){
            double m = (l + r) / 2.0;
            if (a[i].speed.y > 0){
                if (m * a[i].speed.y + a[i].a.y <= minY) l = m;
                else r = m;
            }
            else {
                if (m * a[i].speed.y + a[i].a.y <= minY) r = m;
                else l = m;
            }
        }

        min_y = l;

        l = 0, r = 1e6;

        for (int z = 1; z <= 100; z++){
            double m = (l + r) / 2.0;
            if (a[i].speed.y > 0){
                if (m * a[i].speed.y + a[i].a.y <= maxY) l = m;
                else r = m;
            }
            else {
                if (m * a[i].speed.y + a[i].a.y <= maxY) r = m;
                else l = m;
            }
        }

        max_y = l;

        //

        if ((a[i].a.y <= maxY || a[i].a.y >= minY) && a[i].speed.x == 0 && (a[i].a.x == maxX || a[i].a.x == minX)){
            cout << -1;
            return 0;
        }

        if ((a[i].a.x <= maxX || a[i].a.x >= minX) && a[i].speed.y == 0 && (a[i].a.y == maxY || a[i].a.y == minY)){
            cout << -1;
            return 0;
        }

        if ((a[i].a.y <= maxY || a[i].a.y >= minY) && a[i].speed.y < 0 && a[i].a.y >= maxY && a[i].speed.x == 0){
            cout << -1;
            return 0;
        }

        if ((a[i].a.y <= maxY || a[i].a.y >= minY) && a[i].speed.y > 0 && a[i].a.y <= minY && a[i].speed.x == 0){
            cout << -1;
            return 0;
        }

        if ((a[i].a.x <= maxX || a[i].a.x >= minX) && a[i].speed.x < 0 && a[i].a.x >= maxX && a[i].speed.y == 0){
            cout << -1;
            return 0;
        }

        if ((a[i].a.x <= maxX || a[i].a.x >= minX) && a[i].speed.x > 0 && a[i].a.x <= minX && a[i].speed.y == 0){
            cout << -1;
            return 0;
        }

        if (max_y < min_y) swap(max_y, min_y);

        if (max_x < min_x) swap(max_x, min_x);

        double min_time = max(min_x, min_y);
        double max_time = min(max_x, max_y);

        if (min_time + 0.000000000001 > max_time){
            cout << -1;
            return 0;
        }

        sl.push_back({min_time, 1});
        sl.push_back({max_time + 0.00000001, -1});
    }

    int status = 0;

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

    for (int i = 0; i < sl.size(); i++){
        status += sl[i].second;
        if (status == n){
            cout << sl[i].first;
            return 0;
        }
    }

    cout << -1;
}


#include <bits/stdc++.h>

using namespace std;

void Draganov47(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cout << fixed << setprecision(10);
}

struct pt {
    double x, y;
};

struct vc {
    double x, y;
};

vc gv(pt a, pt b) {
    return {b.x - a.x, b.y - a.y};
}

double ks(vc a, vc b) {
    return (a.x * b.y) - (a.y * b.x);
}

double sc(vc a, vc b) {
    return (a.x + b.x) - (a.y + b.y);
}

const int MAX = 1e5 + 47;

struct mause{
    pt a, b, speed;
};

int n;

pt f, s;

mause a[MAX];

int main(){
    Draganov47();

    cin >> n;

    cin >> f.x >> f.y >> s.x >> s.y;

    double maxX = max(f.x, s.x);
    double minX = min(f.x, s.x);
    double maxY = max(f.y, s.y);
    double minY = min(f.y, s.y);

    vector < pair <double, int> > sl;

    for (int i = 1; i <= n; i++) cin >> a[i].a.x >> a[i].a.y >> a[i].speed.x >> a[i].speed.y;
    for (int i = 1; i <= n; i++){

        double min_x = -1, max_x = -1;

        //

        double l = 0, r = 1e6;

        for (int z = 1; z <= 100; z++){
            double m = (l + r) / 2.0;
            if (a[i].speed.x > 0){
                if (m * a[i].speed.x + a[i].a.x <= minX) l = m;
                else r = m;
            }
            else {
                if (m * a[i].speed.x + a[i].a.x <= minX) r = m;
                else l = m;
            }
        }

        min_x = l;

        l = 0, r = 1e6;

        for (int z = 1; z <= 100; z++){
            double m = (l + r) / 2.0;
            if (a[i].speed.x > 0){
                if (m * a[i].speed.x + a[i].a.x <= maxX) l = m;
                else r = m;
            }
            else {
                if (m * a[i].speed.x + a[i].a.x <= maxX) r = m;
                else l = m;
            }
        }

        max_x = l;

        double min_y = -1, max_y = -1;

        l = 0, r = 1e6;

        for (int z = 1; z <= 100; z++){
            double m = (l + r) / 2.0;
            if (a[i].speed.y > 0){
                if (m * a[i].speed.y + a[i].a.y <= minY) l = m;
                else r = m;
            }
            else {
                if (m * a[i].speed.y + a[i].a.y <= minY) r = m;
                else l = m;
            }
        }

        min_y = l;

        l = 0, r = 1e6;

        for (int z = 1; z <= 100; z++){
            double m = (l + r) / 2.0;
            if (a[i].speed.y > 0){
                if (m * a[i].speed.y + a[i].a.y <= maxY) l = m;
                else r = m;
            }
            else {
                if (m * a[i].speed.y + a[i].a.y <= maxY) r = m;
                else l = m;
            }
        }

        max_y = l;

        //

        if ((a[i].a.y <= maxY || a[i].a.y >= minY) && a[i].speed.x == 0 && (a[i].a.x >= maxX || a[i].a.x <= minX)){
            cout << -1;
            return 0;
        }

        if ((a[i].a.x <= maxX || a[i].a.x >= minX) && a[i].speed.y == 0 && (a[i].a.y >= maxY || a[i].a.y <= minY)){
            cout << -1;
            return 0;
        }

        if (max_y < min_y) swap(max_y, min_y);

        if (max_x < min_x) swap(max_x, min_x);

        double min_time = max(min_x, min_y);
        double max_time = min(max_x, max_y);

        if (min_time + 0.000000000001 > max_time){
            cout << -1;
            return 0;
        }

        sl.push_back({min_time, 1});
        sl.push_back({max_time + 0.00000001, -1});
    }

    int status = 0;

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

    for (int i = 0; i < sl.size(); i++){
        status += sl[i].second;
        if (status == n){
            cout << sl[i].first;
            return 0;
        }
    }

    cout << -1;
}


#include <bits/stdc++.h>

using namespace std;

void Draganov47(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cout << fixed << setprecision(10);
}

struct pt {
    double x, y;
};

struct vc {
    double x, y;
};

vc gv(pt a, pt b) {
    return {b.x - a.x, b.y - a.y};
}

double ks(vc a, vc b) {
    return (a.x * b.y) - (a.y * b.x);
}

double sc(vc a, vc b) {
    return (a.x + b.x) - (a.y + b.y);
}

const int MAX = 1e5 + 47;

struct mause{
    pt a, b, speed;
};

int n;

const double e = 0.00000001;

pt f, s;

mause a[MAX];

int main(){
    Draganov47();

    cin >> n;

    cin >> f.x >> f.y >> s.x >> s.y;

    double maxX = max(f.x, s.x);
    double minX = min(f.x, s.x);
    double maxY = max(f.y, s.y);
    double minY = min(f.y, s.y);

    vector < pair <double, int> > sl;

    for (int i = 1; i <= n; i++) cin >> a[i].a.x >> a[i].a.y >> a[i].speed.x >> a[i].speed.y;
    for (int i = 1; i <= n; i++){

        double min_x = -1, max_x = -1;

        //

        double l = 0, r = 1e6;

        for (int z = 1; z <= 100; z++){
            double m = (l + r) / 2.0;
            if (a[i].speed.x > 0){
                if (m * a[i].speed.x + a[i].a.x <= minX) l = m;
                else r = m;
            }
            else {
                if (m * a[i].speed.x + a[i].a.x <= minX) r = m;
                else l = m;
            }
        }

        min_x = l;

        l = 0, r = 1e6;

        for (int z = 1; z <= 100; z++){
            double m = (l + r) / 2.0;
            if (a[i].speed.x > 0){
                if (m * a[i].speed.x + a[i].a.x <= maxX) l = m;
                else r = m;
            }
            else {
                if (m * a[i].speed.x + a[i].a.x <= maxX) r = m;
                else l = m;
            }
        }

        max_x = l;

        double min_y = -1, max_y = -1;

        l = 0, r = 1e6;

        for (int z = 1; z <= 100; z++){
            double m = (l + r) / 2.0;
            if (a[i].speed.y > 0){
                if (m * a[i].speed.y + a[i].a.y <= minY) l = m;
                else r = m;
            }
            else {
                if (m * a[i].speed.y + a[i].a.y <= minY) r = m;
                else l = m;
            }
        }

        min_y = l;

        l = 0, r = 1e6;

        for (int z = 1; z <= 100; z++){
            double m = (l + r) / 2.0;
            if (a[i].speed.y > 0){
                if (m * a[i].speed.y + a[i].a.y <= maxY) l = m;
                else r = m;
            }
            else {
                if (m * a[i].speed.y + a[i].a.y <= maxY) r = m;
                else l = m;
            }
        }

        max_y = l;

        //

        //cout << min_x << ' ' << max_x << "     " << min_y << ' ' << max_y << endl;

        if (max_y < min_y) swap(max_y, min_y);

        if (max_x < min_x) swap(max_x, min_x);

        double min_time = max(min_x, min_y);
        double max_time = min(max_x, max_y);

        if (min_time - e > max_time + e){
            cout << -1;
            return 0;
        }

        sl.push_back({min_time - e, 1});
        sl.push_back({max_time + e, -1});
    }

    int status = 0;

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

    for (int i = 0; i < sl.size(); i++){
        status += sl[i].second;
        if (status == n){
            cout << sl[i].first;
            return 0;
        }
    }

    cout << -1;
}


#include <bits/stdc++.h>

using namespace std;

void Draganov47(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cout << fixed << setprecision(10);
}

struct pt {
    double x, y;
};

struct vc {
    double x, y;
};

vc gv(pt a, pt b) {
    return {b.x - a.x, b.y - a.y};
}

double ks(vc a, vc b) {
    return (a.x * b.y) - (a.y * b.x);
}

double sc(vc a, vc b) {
    return (a.x + b.x) - (a.y + b.y);
}

const int MAX = 1e5 + 47;

struct mause{
    pt a, b, speed;
};

int n;

pt f, s;

mause a[MAX];

int main(){
    Draganov47();

    cin >> n;

    cin >> f.x >> f.y >> s.x >> s.y;

    double maxX = max(f.x, s.x);
    double minX = min(f.x, s.x);
    double maxY = max(f.y, s.y);
    double minY = min(f.y, s.y);

    vector < pair <double, int> > sl;

    for (int i = 1; i <= n; i++) cin >> a[i].a.x >> a[i].a.y >> a[i].speed.x >> a[i].speed.y;
    for (int i = 1; i <= n; i++){

        double min_x = -1, max_x = -1;

        //

        double l = 0, r = 1e6;

        for (int z = 1; z <= 100; z++){
            double m = (l + r) / 2.0;
            if (a[i].speed.x > 0){
                if (m * a[i].speed.x + a[i].a.x <= minX) l = m;
                else r = m;
            }
            else {
                if (m * a[i].speed.x + a[i].a.x <= minX) r = m;
                else l = m;
            }
        }

        min_x = l;

        l = 0, r = 1e6;

        for (int z = 1; z <= 100; z++){
            double m = (l + r) / 2.0;
            if (a[i].speed.x > 0){
                if (m * a[i].speed.x + a[i].a.x <= maxX) l = m;
                else r = m;
            }
            else {
                if (m * a[i].speed.x + a[i].a.x <= maxX) r = m;
                else l = m;
            }
        }

        max_x = l;

        double min_y = -1, max_y = -1;

        l = 0, r = 1e6;

        for (int z = 1; z <= 100; z++){
            double m = (l + r) / 2.0;
            if (a[i].speed.y > 0){
                if (m * a[i].speed.y + a[i].a.y <= minY) l = m;
                else r = m;
            }
            else {
                if (m * a[i].speed.y + a[i].a.y <= minY) r = m;
                else l = m;
            }
        }

        min_y = l;

        l = 0, r = 1e6;

        for (int z = 1; z <= 100; z++){
            double m = (l + r) / 2.0;
            if (a[i].speed.y > 0){
                if (m * a[i].speed.y + a[i].a.y <= maxY) l = m;
                else r = m;
            }
            else {
                if (m * a[i].speed.y + a[i].a.y <= maxY) r = m;
                else l = m;
            }
        }

        max_y = l;

        //

        if ((a[i].a.y <= maxY || a[i].a.y >= minY) && a[i].speed.x == 0 && (a[i].a.x == maxX || a[i].a.x == minX)){
            cout << -1;
            return 0;
        }

        if ((a[i].a.x <= maxX || a[i].a.x >= minX) && a[i].speed.y == 0 && (a[i].a.y == maxY || a[i].a.y == minY)){
            cout << -1;
            return 0;
        }

        if (a[i].speed.y < 0 && a[i].a.y >= maxY && a[i].speed.x == 0){
            cout << -1;
            return 0;
        }

        if (a[i].speed.y > 0 && a[i].a.y <= minY && a[i].speed.x == 0){
            cout << -1;
            return 0;
        }

        if (a[i].speed.x < 0 && a[i].a.x >= maxX && a[i].speed.y == 0){
            cout << -1;
            return 0;
        }

        if (a[i].speed.x > 0 && a[i].a.x <= minX && a[i].speed.y == 0){
            cout << -1;
            return 0;
        }

        if (max_y < min_y) swap(max_y, min_y);

        if (max_x < min_x) swap(max_x, min_x);

        double min_time = max(min_x, min_y);
        double max_time = min(max_x, max_y);

        if (min_time + 0.000000000001 > max_time){
            cout << -1;
            return 0;
        }

        sl.push_back({min_time, 1});
        sl.push_back({max_time + 0.00000001, -1});
    }

    int status = 0;

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

    for (int i = 0; i < sl.size(); i++){
        status += sl[i].second;
        if (status == n){
            cout << sl[i].first;
            return 0;
        }
    }

    cout << -1;
}


#include <bits/stdc++.h>

using namespace std;

void Draganov47(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cout << fixed << setprecision(10);
}

struct pt {
    double x, y;
};

struct vc {
    double x, y;
};

vc gv(pt a, pt b) {
    return {b.x - a.x, b.y - a.y};
}

double ks(vc a, vc b) {
    return (a.x * b.y) - (a.y * b.x);
}

double sc(vc a, vc b) {
    return (a.x + b.x) - (a.y + b.y);
}

const int MAX = 1e5 + 47;

struct mause{
    pt a, b, speed;
};

int n;

pt f, s;

mause a[MAX];

int main(){
    Draganov47();

    cin >> n;

    cin >> f.x >> f.y >> s.x >> s.y;

    double maxX = max(f.x, s.x);
    double minX = min(f.x, s.x);
    double maxY = max(f.y, s.y);
    double minY = min(f.y, s.y);

    vector < pair <double, int> > sl;

    for (int i = 1; i <= n; i++) cin >> a[i].a.x >> a[i].a.y >> a[i].speed.x >> a[i].speed.y;
    for (int i = 1; i <= n; i++){

        double min_x = -1, max_x = -1;

        //

        double l = 0, r = 1e6;

        for (int z = 1; z <= 100; z++){
            double m = (l + r) / 2.0;
            if (a[i].speed.x > 0){
                if (m * a[i].speed.x + a[i].a.x <= minX) l = m;
                else r = m;
            }
            else {
                if (m * a[i].speed.x + a[i].a.x <= minX) r = m;
                else l = m;
            }
        }

        min_x = l;

        l = 0, r = 1e6;

        for (int z = 1; z <= 100; z++){
            double m = (l + r) / 2.0;
            if (a[i].speed.x > 0){
                if (m * a[i].speed.x + a[i].a.x <= maxX) l = m;
                else r = m;
            }
            else {
                if (m * a[i].speed.x + a[i].a.x <= maxX) r = m;
                else l = m;
            }
        }

        max_x = l;

        double min_y = -1, max_y = -1;

        l = 0, r = 1e6;

        for (int z = 1; z <= 100; z++){
            double m = (l + r) / 2.0;
            if (a[i].speed.y > 0){
                if (m * a[i].speed.y + a[i].a.y <= minY) l = m;
                else r = m;
            }
            else {
                if (m * a[i].speed.y + a[i].a.y <= minY) r = m;
                else l = m;
            }
        }

        min_y = l;

        l = 0, r = 1e6;

        for (int z = 1; z <= 100; z++){
            double m = (l + r) / 2.0;
            if (a[i].speed.y > 0){
                if (m * a[i].speed.y + a[i].a.y <= maxY) l = m;
                else r = m;
            }
            else {
                if (m * a[i].speed.y + a[i].a.y <= maxY) r = m;
                else l = m;
            }
        }

        max_y = l;

        //

        if (a[i].a.x <= maxX && a[i].a.x >= minX && a[i].speed.x == 0 && a[i].speed.y == 0){
            cout << -1;
            return 0;
        }

        if (a[i].a.y <= maxY && a[i].a.y >= minY && a[i].speed.y == 0 && a[i].speed.x == 0){
            cout << -1;
            return 0;
        }

        //cout << min_x << ' ' << max_x << "     " << min_y << ' ' << max_y << endl;

        if (max_y < min_y) swap(max_y, min_y);

        if (max_x < min_x) swap(max_x, min_x);

        double min_time = max(min_x, min_y);
        double max_time = min(max_x, max_y);

        //cout << min_time << ' ' << max_time << endl;

        if (min_time + 0.000000000001 > max_time){
            cout << -1;
            return 0;
        }

        sl.push_back({min_time, 1});
        sl.push_back({max_time + 0.00000001, -1});
    }

    int status = 0;

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

    for (int i = 0; i < sl.size(); i++){
        status += sl[i].second;
        if (status == n){
            cout << sl[i].first;
            return 0;
        }
    }

    cout << -1;
}


#include <bits/stdc++.h>

using namespace std;

void Draganov47(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cout << fixed << setprecision(10);
}

struct pt {
    double x, y;
};

struct vc {
    double x, y;
};

vc gv(pt a, pt b) {
    return {b.x - a.x, b.y - a.y};
}

double ks(vc a, vc b) {
    return (a.x * b.y) - (a.y * b.x);
}

double sc(vc a, vc b) {
    return (a.x + b.x) - (a.y + b.y);
}

const int MAX = 1e5 + 47;

struct mause{
    pt a, b, speed;
};

int n;

pt f, s;

mause a[MAX];

void valid(mause a){
    a.b.x = a.a.x + a.speed.x;
    a.b.y = a.a.y + a.speed.y;
    bool f11, f22, f33, f44;
    pt f1, s1;
    f1.x = f.x;
    f1.y = s.y;
    s1.x = s.x;
    s1.y = f.y;
    f11 = (ks(gv(a.a, a.b), gv(f, f1)) == 0 && (ks(gv(f, a.a), gv(f, f1)) == 0 || ks(gv(f, a.b), gv(f, f1)) == 0));
    f22 = (ks(gv(a.a, a.b), gv(s, f1)) == 0 && (ks(gv(s, a.a), gv(s, f1)) == 0 || ks(gv(s, a.b), gv(s, f1)) == 0));
    f33 = (ks(gv(a.a, a.b), gv(s1, f)) == 0 && (ks(gv(s1, a.a), gv(s1, f)) == 0 || ks(gv(s1, a.b), gv(s1, f)) == 0));
    f44 = (ks(gv(a.a, a.b), gv(s1, s)) == 0 && (ks(gv(s1, a.a), gv(s1, s)) == 0 || ks(gv(s1, a.b), gv(s1, s)) == 0));
    if (f11 || f22 || f33 || f44){
        cout << -1;
        exit(0);
    }
}

int main(){
    Draganov47();

    cin >> n;

    cin >> f.x >> f.y >> s.x >> s.y;

    double maxX = max(f.x, s.x);
    double minX = min(f.x, s.x);
    double maxY = max(f.y, s.y);
    double minY = min(f.y, s.y);

    vector < pair <double, int> > sl;

    for (int i = 1; i <= n; i++) cin >> a[i].a.x >> a[i].a.y >> a[i].speed.x >> a[i].speed.y, valid(a[i]);
    for (int i = 1; i <= n; i++){

        double min_x = -1, max_x = -1;

        //

        double l = 0, r = 1e6;

        for (int z = 1; z <= 100; z++){
            double m = (l + r) / 2.0;
            if (a[i].speed.x > 0){
                if (m * a[i].speed.x + a[i].a.x <= minX) l = m;
                else r = m;
            }
            else {
                if (m * a[i].speed.x + a[i].a.x <= minX) r = m;
                else l = m;
            }
        }

        min_x = l;

        l = 0, r = 1e6;

        for (int z = 1; z <= 100; z++){
            double m = (l + r) / 2.0;
            if (a[i].speed.x > 0){
                if (m * a[i].speed.x + a[i].a.x <= maxX) l = m;
                else r = m;
            }
            else {
                if (m * a[i].speed.x + a[i].a.x <= maxX) r = m;
                else l = m;
            }
        }

        max_x = l;

        double min_y = -1, max_y = -1;

        l = 0, r = 1e6;

        for (int z = 1; z <= 100; z++){
            double m = (l + r) / 2.0;
            if (a[i].speed.y > 0){
                if (m * a[i].speed.y + a[i].a.y <= minY) l = m;
                else r = m;
            }
            else {
                if (m * a[i].speed.y + a[i].a.y <= minY) r = m;
                else l = m;
            }
        }

        min_y = l;

        l = 0, r = 1e6;

        for (int z = 1; z <= 100; z++){
            double m = (l + r) / 2.0;
            if (a[i].speed.y > 0){
                if (m * a[i].speed.y + a[i].a.y <= maxY) l = m;
                else r = m;
            }
            else {
                if (m * a[i].speed.y + a[i].a.y <= maxY) r = m;
                else l = m;
            }
        }

        max_y = l;

        //

        if (max_y < min_y) swap(max_y, min_y);

        if (max_x < min_x) swap(max_x, min_x);

        double min_time = max(min_x, min_y);
        double max_time = min(max_x, max_y);

        if (min_time > max_time + 0.00001){
            cout << -1;
            return 0;
        }

        sl.push_back({min_time, 1});
        sl.push_back({max_time + 0.00001, -1});
    }

    int status = 0;

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

    for (int i = 0; i < sl.size(); i++){
        status += sl[i].second;
        if (status == n){
            cout << sl[i].first;
            return 0;
        }
    }

    cout << -1;
}


#include <bits/stdc++.h>

using namespace std;

void Draganov47(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cout << fixed << setprecision(10);
}

struct pt {
    double x, y;
};

struct vc {
    double x, y;
};

vc gv(pt a, pt b) {
    return {b.x - a.x, b.y - a.y};
}

double ks(vc a, vc b) {
    return (a.x * b.y) - (a.y * b.x);
}

double sc(vc a, vc b) {
    return (a.x + b.x) - (a.y + b.y);
}

const int MAX = 1e5 + 47;

struct mause{
    pt a, b, speed;
};

int n;

pt f, s;

mause a[MAX];

int main(){
    Draganov47();

    cin >> n;

    cin >> f.x >> f.y >> s.x >> s.y;

    double maxX = max(f.x, s.x);
    double minX = min(f.x, s.x);
    double maxY = max(f.y, s.y);
    double minY = min(f.y, s.y);

    vector < pair <double, int> > sl;

    for (int i = 1; i <= n; i++) cin >> a[i].a.x >> a[i].a.y >> a[i].speed.x >> a[i].speed.y;
    for (int i = 1; i <= n; i++){

        double min_x = -1, max_x = -1;

        //

        double l = 0, r = 1e6;

        for (int z = 1; z <= 100; z++){
            double m = (l + r) / 2.0;
            if (a[i].speed.x > 0){
                if (m * a[i].speed.x + a[i].a.x <= minX) l = m;
                else r = m;
            }
            else {
                if (m * a[i].speed.x + a[i].a.x <= minX) r = m;
                else l = m;
            }
        }

        min_x = l;

        l = 0, r = 1e6;

        for (int z = 1; z <= 100; z++){
            double m = (l + r) / 2.0;
            if (a[i].speed.x > 0){
                if (m * a[i].speed.x + a[i].a.x <= maxX) l = m;
                else r = m;
            }
            else {
                if (m * a[i].speed.x + a[i].a.x <= maxX) r = m;
                else l = m;
            }
        }

        max_x = l;

        double min_y = -1, max_y = -1;

        l = 0, r = 1e6;

        for (int z = 1; z <= 100; z++){
            double m = (l + r) / 2.0;
            if (a[i].speed.y > 0){
                if (m * a[i].speed.y + a[i].a.y <= minY) l = m;
                else r = m;
            }
            else {
                if (m * a[i].speed.y + a[i].a.y <= minY) r = m;
                else l = m;
            }
        }

        min_y = l;

        l = 0, r = 1e6;

        for (int z = 1; z <= 100; z++){
            double m = (l + r) / 2.0;
            if (a[i].speed.y > 0){
                if (m * a[i].speed.y + a[i].a.y <= maxY) l = m;
                else r = m;
            }
            else {
                if (m * a[i].speed.y + a[i].a.y <= maxY) r = m;
                else l = m;
            }
        }

        max_y = l;

        //

        if ((a[i].a.y <= maxY || a[i].a.y >= minY) && a[i].speed.x == 0 && (a[i].a.x == maxX || a[i].a.x == minX)){
            cout << -1;
            return 0;
        }

        if ((a[i].a.x <= maxX || a[i].a.x >= minX) && a[i].speed.y == 0 && (a[i].a.y == maxY || a[i].a.y == minY)){
            cout << -1;
            return 0;
        }

        if ((a[i].a.x <= maxX || a[i].a.x >= minX) && a[i].speed.y < 0 && a[i].a.y >= maxY && a[i].speed.x == 0){
            cout << -1;
            return 0;
        }

        if ((a[i].a.x <= maxX || a[i].a.x >= minX) && a[i].speed.y > 0 && a[i].a.y <= minY && a[i].speed.x == 0){
            cout << -1;
            return 0;
        }

        if ((a[i].a.y <= maxY || a[i].a.y >= minY) && a[i].speed.x < 0 && a[i].a.x >= maxX && a[i].speed.y == 0){
            cout << -1;
            return 0;
        }

        if ((a[i].a.y <= maxY || a[i].a.y >= minY) && a[i].speed.x > 0 && a[i].a.x <= minX && a[i].speed.y == 0){
            cout << -1;
            return 0;
        }

        if (max_y < min_y) swap(max_y, min_y);

        if (max_x < min_x) swap(max_x, min_x);

        double min_time = max(min_x, min_y);

        double max_time = min(max_x, max_y);

        if (min_time + 0.000000000001 > max_time){
            cout << -1;
            return 0;
        }

        sl.push_back({min_time, 1});
        sl.push_back({max_time + 0.00000001, -1});
    }

    int status = 0;

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

    for (int i = 0; i < sl.size(); i++){
        status += sl[i].second;
        if (status == n){
            cout << sl[i].first;
            return 0;
        }
    }

    cout << -1;
}


#include <bits/stdc++.h>

using namespace std;

void Draganov47(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cout << fixed << setprecision(10);
}

struct pt {
    double x, y;
};

struct vc {
    double x, y;
};

vc gv(pt a, pt b) {
    return {b.x - a.x, b.y - a.y};
}

double ks(vc a, vc b) {
    return (a.x * b.y) - (a.y * b.x);
}

double sc(vc a, vc b) {
    return (a.x + b.x) - (a.y + b.y);
}

const int MAX = 1e5 + 47;

struct mause{
    pt a, b, speed;
};

int n;

pt f, s;

mause a[MAX];

int main(){
    Draganov47();

    cin >> n;

    cin >> f.x >> f.y >> s.x >> s.y;

    double maxX = max(f.x, s.x);
    double minX = min(f.x, s.x);
    double maxY = max(f.y, s.y);
    double minY = min(f.y, s.y);

    vector < pair <double, int> > sl;

    for (int i = 1; i <= n; i++) cin >> a[i].a.x >> a[i].a.y >> a[i].speed.x >> a[i].speed.y;
    for (int i = 1; i <= n; i++){

        double min_x = -1, max_x = -1;

        //

        double l = 0, r = 1e6;

        for (int z = 1; z <= 100; z++){
            double m = (l + r) / 2.0;
            if (a[i].speed.x > 0){
                if (m * a[i].speed.x + a[i].a.x <= minX) l = m;
                else r = m;
            }
            else {
                if (m * a[i].speed.x + a[i].a.x <= minX) r = m;
                else l = m;
            }
        }

        min_x = l;

        l = 0, r = 1e6;

        for (int z = 1; z <= 100; z++){
            double m = (l + r) / 2.0;
            if (a[i].speed.x > 0){
                if (m * a[i].speed.x + a[i].a.x <= maxX) l = m;
                else r = m;
            }
            else {
                if (m * a[i].speed.x + a[i].a.x <= maxX) r = m;
                else l = m;
            }
        }

        max_x = l;

        double min_y = -1, max_y = -1;

        l = 0, r = 1e6;

        for (int z = 1; z <= 100; z++){
            double m = (l + r) / 2.0;
            if (a[i].speed.y > 0){
                if (m * a[i].speed.y + a[i].a.y <= minY) l = m;
                else r = m;
            }
            else {
                if (m * a[i].speed.y + a[i].a.y <= minY) r = m;
                else l = m;
            }
        }

        min_y = l;

        l = 0, r = 1e6;

        for (int z = 1; z <= 100; z++){
            double m = (l + r) / 2.0;
            if (a[i].speed.y > 0){
                if (m * a[i].speed.y + a[i].a.y <= maxY) l = m;
                else r = m;
            }
            else {
                if (m * a[i].speed.y + a[i].a.y <= maxY) r = m;
                else l = m;
            }
        }

        max_y = l;

        //

        if (a[i].speed.y > 0 && a[i].a.y <= maxY) a[i].a.y = maxY;
        if (a[i].speed.y < 0 && a[i].a.y >= maxY) a[i].a.y = maxY;

        if (a[i].speed.x > 0 && a[i].a.x <= maxX) a[i].a.x = maxX;
        if (a[i].speed.x < 0 && a[i].a.x >= maxX) a[i].a.x = maxX;

        if ((a[i].a.y <= maxY || a[i].a.y >= minY) && a[i].speed.x == 0 && (a[i].a.x == maxX || a[i].a.x == minX)){
            cout << -1;
            return 0;
        }

        if ((a[i].a.x <= maxX || a[i].a.x >= minX) && a[i].speed.y == 0 && (a[i].a.y == maxY || a[i].a.y == minY)){
            cout << -1;
            return 0;
        }

        if (max_y < min_y) swap(max_y, min_y);

        if (max_x < min_x) swap(max_x, min_x);

        double min_time = max(min_x, min_y);
        double max_time = min(max_x, max_y);

        if (min_time + 0.000000000001 > max_time){
            cout << -1;
            return 0;
        }

        sl.push_back({min_time, 1});
        sl.push_back({max_time - 0.00000000001, -1});
    }

    int status = 0;

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

    for (int i = 0; i < sl.size(); i++){
        status += sl[i].second;
        if (status == n){
            cout << sl[i].first;
            return 0;
        }
    }

    cout << -1;
}


#include <bits/stdc++.h>

using namespace std;

void Draganov47(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cout << fixed << setprecision(10);
}

struct pt {
    double x, y;
};

struct vc {
    double x, y;
};

vc gv(pt a, pt b) {
    return {b.x - a.x, b.y - a.y};
}

double ks(vc a, vc b) {
    return (a.x * b.y) - (a.y * b.x);
}

double sc(vc a, vc b) {
    return (a.x + b.x) - (a.y + b.y);
}

const int MAX = 1e5 + 47;

struct mause{
    pt a, b, speed;
};

int n;

pt f, s;

mause a[MAX];

int main(){
    Draganov47();

    cin >> n;

    cin >> f.x >> f.y >> s.x >> s.y;

    double maxX = max(f.x, s.x);
    double minX = min(f.x, s.x);
    double maxY = max(f.y, s.y);
    double minY = min(f.y, s.y);

    vector < pair <double, int> > sl;

    for (int i = 1; i <= n; i++) cin >> a[i].a.x >> a[i].a.y >> a[i].speed.x >> a[i].speed.y;
    for (int i = 1; i <= n; i++){

        double min_x = -1, max_x = -1;

        //

        double l = 0, r = 1e6;

        for (int z = 1; z <= 100; z++){
            double m = (l + r) / 2.0;
            if (a[i].speed.x > 0){
                if (m * a[i].speed.x + a[i].a.x <= minX) l = m;
                else r = m;
            }
            else {
                if (m * a[i].speed.x + a[i].a.x <= minX) r = m;
                else l = m;
            }
        }

        min_x = l;

        l = 0, r = 1e6;

        for (int z = 1; z <= 100; z++){
            double m = (l + r) / 2.0;
            if (a[i].speed.x > 0){
                if (m * a[i].speed.x + a[i].a.x <= maxX) l = m;
                else r = m;
            }
            else {
                if (m * a[i].speed.x + a[i].a.x <= maxX) r = m;
                else l = m;
            }
        }

        max_x = l;

        double min_y = -1, max_y = -1;

        l = 0, r = 1e6;

        for (int z = 1; z <= 100; z++){
            double m = (l + r) / 2.0;
            if (a[i].speed.y > 0){
                if (m * a[i].speed.y + a[i].a.y <= minY) l = m;
                else r = m;
            }
            else {
                if (m * a[i].speed.y + a[i].a.y <= minY) r = m;
                else l = m;
            }
        }

        min_y = l;

        l = 0, r = 1e6;

        for (int z = 1; z <= 100; z++){
            double m = (l + r) / 2.0;
            if (a[i].speed.y > 0){
                if (m * a[i].speed.y + a[i].a.y <= maxY) l = m;
                else r = m;
            }
            else {
                if (m * a[i].speed.y + a[i].a.y <= maxY) r = m;
                else l = m;
            }
        }

        max_y = l;

        //

        if ((a[i].a.y >= minY && a[i].a.y <= maxY) && a[i].a.x <= maxX && a[i].a.x >= minX && a[i].speed.x == 0){
            cout << -1;
            return 0;
        }

        if ((a[i].a.x >= minX && a[i].a.x <= maxX) && a[i].a.y <= maxY && a[i].a.y >= minY && a[i].speed.y == 0){
            cout << -1;
            return 0;
        }

        //cout << min_x << ' ' << max_x << "     " << min_y << ' ' << max_y << endl;

        if (max_y < min_y) swap(max_y, min_y);

        if (max_x < min_x) swap(max_x, min_x);

        double min_time = max(min_x, min_y);
        double max_time = min(max_x, max_y);

        //cout << min_time << ' ' << max_time << endl;

        if (min_time + 0.000000000001 > max_time){
            cout << -1;
            return 0;
        }

        sl.push_back({min_time, 1});
        sl.push_back({max_time + 0.00000001, -1});
    }

    int status = 0;

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

    for (int i = 0; i < sl.size(); i++){
        status += sl[i].second;
        if (status == n){
            cout << sl[i].first;
            return 0;
        }
    }

    cout << -1;
}


#include <bits/stdc++.h>

using namespace std;

void Draganov47(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cout << fixed << setprecision(10);
}

struct pt {
    double x, y;
};

struct vc {
    double x, y;
};

vc gv(pt a, pt b) {
    return {b.x - a.x, b.y - a.y};
}

double ks(vc a, vc b) {
    return (a.x * b.y) - (a.y * b.x);
}

double sc(vc a, vc b) {
    return (a.x + b.x) - (a.y + b.y);
}

const int MAX = 1e5 + 47;

struct mause{
    pt a, b, speed;
};

int n;

pt f, s;

mause a[MAX];

int main(){
    Draganov47();

    cin >> n;

    cin >> f.x >> f.y >> s.x >> s.y;

    double maxX = max(f.x, s.x);
    double minX = min(f.x, s.x);
    double maxY = max(f.y, s.y);
    double minY = min(f.y, s.y);

    vector < pair <double, int> > sl;

    for (int i = 1; i <= n; i++) cin >> a[i].a.x >> a[i].a.y >> a[i].speed.x >> a[i].speed.y;
    for (int i = 1; i <= n; i++){

        double min_x = -1, max_x = -1;

        //

        double l = 0, r = 1e6;

        for (int z = 1; z <= 100; z++){
            double m = (l + r) / 2.0;
            if (a[i].speed.x > 0){
                if (m * a[i].speed.x + a[i].a.x <= minX) l = m;
                else r = m;
            }
            else {
                if (m * a[i].speed.x + a[i].a.x <= minX) r = m;
                else l = m;
            }
        }

        min_x = l;

        l = 0, r = 1e6;

        for (int z = 1; z <= 100; z++){
            double m = (l + r) / 2.0;
            if (a[i].speed.x > 0){
                if (m * a[i].speed.x + a[i].a.x <= maxX) l = m;
                else r = m;
            }
            else {
                if (m * a[i].speed.x + a[i].a.x <= maxX) r = m;
                else l = m;
            }
        }

        max_x = l;

        double min_y = -1, max_y = -1;

        l = 0, r = 1e6;

        for (int z = 1; z <= 100; z++){
            double m = (l + r) / 2.0;
            if (a[i].speed.y > 0){
                if (m * a[i].speed.y + a[i].a.y <= minY) l = m;
                else r = m;
            }
            else {
                if (m * a[i].speed.y + a[i].a.y <= minY) r = m;
                else l = m;
            }
        }

        min_y = l;

        l = 0, r = 1e6;

        for (int z = 1; z <= 100; z++){
            double m = (l + r) / 2.0;
            if (a[i].speed.y > 0){
                if (m * a[i].speed.y + a[i].a.y <= maxY) l = m;
                else r = m;
            }
            else {
                if (m * a[i].speed.y + a[i].a.y <= maxY) r = m;
                else l = m;
            }
        }

        max_y = l;

        //

        //cout << min_x << ' ' << max_x << "     " << min_y << ' ' << max_y << endl;

        if (max_y < min_y) swap(max_y, min_y);

        if (max_x < min_x) swap(max_x, min_x);

        double min_time = max(min_x, min_y);
        double max_time = min(max_x, max_y);

        if (min_time > max_time + 0.00001){
            cout << -1;
            return 0;
        }

        sl.push_back({min_time, 1});
        sl.push_back({max_time + 0.00001, -1});
    }

    int status = 0;

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

    for (int i = 0; i < sl.size(); i++){
        status += sl[i].second;
        if (status == n){
            cout << sl[i].first;
            return 0;
        }
    }

    cout << -1;
}


#include <bits/stdc++.h>

using namespace std;

void Draganov47(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cout << fixed << setprecision(10);
}

struct pt {
    double x, y;
};

struct vc {
    double x, y;
};

vc gv(pt a, pt b) {
    return {b.x - a.x, b.y - a.y};
}

double ks(vc a, vc b) {
    return (a.x * b.y) - (a.y * b.x);
}

double sc(vc a, vc b) {
    return (a.x + b.x) - (a.y + b.y);
}

const int MAX = 1e5 + 47;

struct mause{
    pt a, b, speed;
};

int n;

pt f, s;

mause a[MAX];

int main(){
    Draganov47();

    cin >> n;

    cin >> f.x >> f.y >> s.x >> s.y;

    double maxX = max(f.x, s.x);
    double minX = min(f.x, s.x);
    double maxY = max(f.y, s.y);
    double minY = min(f.y, s.y);

    vector < pair <double, int> > sl;

    for (int i = 1; i <= n; i++) cin >> a[i].a.x >> a[i].a.y >> a[i].speed.x >> a[i].speed.y;
    for (int i = 1; i <= n; i++){

        double min_x = -1, max_x = -1;

        //

        double l = 0, r = 1e6;

        for (int z = 1; z <= 100; z++){
            double m = (l + r) / 2.0;
            if (a[i].speed.x > 0){
                if (m * a[i].speed.x + a[i].a.x <= minX) l = m;
                else r = m;
            }
            else {
                if (m * a[i].speed.x + a[i].a.x <= minX) r = m;
                else l = m;
            }
        }

        min_x = l;

        l = 0, r = 1e6;

        for (int z = 1; z <= 100; z++){
            double m = (l + r) / 2.0;
            if (a[i].speed.x > 0){
                if (m * a[i].speed.x + a[i].a.x <= maxX) l = m;
                else r = m;
            }
            else {
                if (m * a[i].speed.x + a[i].a.x <= maxX) r = m;
                else l = m;
            }
        }

        max_x = l;

        double min_y = -1, max_y = -1;

        l = 0, r = 1e6;

        for (int z = 1; z <= 100; z++){
            double m = (l + r) / 2.0;
            if (a[i].speed.y > 0){
                if (m * a[i].speed.y + a[i].a.y <= minY) l = m;
                else r = m;
            }
            else {
                if (m * a[i].speed.y + a[i].a.y <= minY) r = m;
                else l = m;
            }
        }

        min_y = l;

        l = 0, r = 1e6;

        for (int z = 1; z <= 100; z++){
            double m = (l + r) / 2.0;
            if (a[i].speed.y > 0){
                if (m * a[i].speed.y + a[i].a.y <= maxY) l = m;
                else r = m;
            }
            else {
                if (m * a[i].speed.y + a[i].a.y <= maxY) r = m;
                else l = m;
            }
        }

        max_y = l;

        //

        if (a[i].a.y <= maxY && a[i].a.y >= minY && a[i].speed.x == 0 && (a[i].a.x == maxX || a[i].a.x == minX)){
            cout << -1;
            return 0;
        }

        if (a[i].a.x <= maxX && a[i].a.x >= minX && a[i].speed.y == 0 && (a[i].a.y == maxY || a[i].a.y == minY)){
            cout << -1;
            return 0;
        }

        if (max_y < min_y) swap(max_y, min_y);

        if (max_x < min_x) swap(max_x, min_x);

        double min_time = max(min_x, min_y);
        double max_time = min(max_x, max_y);

        if (min_time + 0.000000000001 > max_time){
            cout << -1;
            return 0;
        }

        sl.push_back({min_time, 1});
        sl.push_back({max_time + 0.00000001, -1});
    }

    int status = 0;

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

    for (int i = 0; i < sl.size(); i++){
        status += sl[i].second;
        if (status == n){
            cout << sl[i].first;
            return 0;
        }
    }

    cout << -1;
}


#include <bits/stdc++.h>

using namespace std;

void Draganov47(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cout << fixed << setprecision(10);
}

struct pt {
    double x, y;
};

struct vc {
    double x, y;
};

vc gv(pt a, pt b) {
    return {b.x - a.x, b.y - a.y};
}

double ks(vc a, vc b) {
    return (a.x * b.y) - (a.y * b.x);
}

double sc(vc a, vc b) {
    return (a.x + b.x) - (a.y + b.y);
}

const int MAX = 1e5 + 47;

struct mause{
    pt a, b, speed;
};

int n;

pt f, s;

mause a[MAX];

void valid(mause a){
    a.b.x = a.a.x + a.speed.x;
    a.b.y = a.a.y + a.speed.y;
    bool f11, f22, f33, f44;
    pt f1, s1;
    f1.x = f.x;
    f1.y = s.y;
    s1.x = s.x;
    s1.y = f.y;
    f11 = (ks(gv(a.a, a.b), gv(f, f1)) == 0 && ks(gv(f, a.a), gv(f, f1)) == 0);
    f22 = (ks(gv(a.a, a.b), gv(s, f1)) == 0 && ks(gv(s, a.a), gv(s, f1)) == 0);
    f33 = (ks(gv(a.a, a.b), gv(s1, f)) == 0 && ks(gv(s1, a.a), gv(s1, f)) == 0);
    f44 = (ks(gv(a.a, a.b), gv(s1, s)) == 0 && ks(gv(s1, a.a), gv(s1, s)) == 0);
    if (f11 || f22 || f33 || f44){
        cout << -1;
        exit(0);
    }
}

int main(){
    Draganov47();

    cin >> n;

    cin >> f.x >> f.y >> s.x >> s.y;

    double maxX = max(f.x, s.x);
    double minX = min(f.x, s.x);
    double maxY = max(f.y, s.y);
    double minY = min(f.y, s.y);

    vector < pair <double, int> > sl;

    for (int i = 1; i <= n; i++) cin >> a[i].a.x >> a[i].a.y >> a[i].speed.x >> a[i].speed.y, valid(a[i]);
    for (int i = 1; i <= n; i++){

        double min_x = -1, max_x = -1;

        //

        double l = 0, r = 1e6;

        for (int z = 1; z <= 100; z++){
            double m = (l + r) / 2.0;
            if (a[i].speed.x > 0){
                if (m * a[i].speed.x + a[i].a.x <= minX) l = m;
                else r = m;
            }
            else {
                if (m * a[i].speed.x + a[i].a.x <= minX) r = m;
                else l = m;
            }
        }

        min_x = l;

        l = 0, r = 1e6;

        for (int z = 1; z <= 100; z++){
            double m = (l + r) / 2.0;
            if (a[i].speed.x > 0){
                if (m * a[i].speed.x + a[i].a.x <= maxX) l = m;
                else r = m;
            }
            else {
                if (m * a[i].speed.x + a[i].a.x <= maxX) r = m;
                else l = m;
            }
        }

        max_x = l;

        double min_y = -1, max_y = -1;

        l = 0, r = 1e6;

        for (int z = 1; z <= 100; z++){
            double m = (l + r) / 2.0;
            if (a[i].speed.y > 0){
                if (m * a[i].speed.y + a[i].a.y <= minY) l = m;
                else r = m;
            }
            else {
                if (m * a[i].speed.y + a[i].a.y <= minY) r = m;
                else l = m;
            }
        }

        min_y = l;

        l = 0, r = 1e6;

        for (int z = 1; z <= 100; z++){
            double m = (l + r) / 2.0;
            if (a[i].speed.y > 0){
                if (m * a[i].speed.y + a[i].a.y <= maxY) l = m;
                else r = m;
            }
            else {
                if (m * a[i].speed.y + a[i].a.y <= maxY) r = m;
                else l = m;
            }
        }

        max_y = l;

        //

        if (max_y < min_y) swap(max_y, min_y);

        if (max_x < min_x) swap(max_x, min_x);

        double min_time = max(min_x, min_y);
        double max_time = min(max_x, max_y);

        if (min_time > max_time + 0.00001){
            cout << -1;
            return 0;
        }

        sl.push_back({min_time, 1});
        sl.push_back({max_time + 0.00001, -1});
    }

    int status = 0;

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

    for (int i = 0; i < sl.size(); i++){
        status += sl[i].second;
        if (status == n){
            cout << sl[i].first;
            return 0;
        }
    }

    cout << -1;
}


#include <bits/stdc++.h>

using namespace std;

void Draganov47(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cout << fixed << setprecision(10);
}

struct pt {
    double x, y;
};

struct vc {
    double x, y;
};

vc gv(pt a, pt b) {
    return {b.x - a.x, b.y - a.y};
}

double ks(vc a, vc b) {
    return (a.x * b.y) - (a.y * b.x);
}

double sc(vc a, vc b) {
    return (a.x + b.x) - (a.y + b.y);
}

const int MAX = 1e5 + 47;

struct mause{
    pt a, b, speed;
};

int n;

pt f, s;

mause a[MAX];

int main(){
    Draganov47();

    cin >> n;

    cin >> f.x >> f.y >> s.x >> s.y;

    double maxX = max(f.x, s.x);
    double minX = min(f.x, s.x);
    double maxY = max(f.y, s.y);
    double minY = min(f.y, s.y);

    vector < pair <double, int> > sl;

    for (int i = 1; i <= n; i++) cin >> a[i].a.x >> a[i].a.y >> a[i].speed.x >> a[i].speed.y;
    for (int i = 1; i <= n; i++){

        double min_x = -1, max_x = -1;

        //

        double l = 0, r = 1e6;

        for (int z = 1; z <= 100; z++){
            double m = (l + r) / 2.0;
            if (a[i].speed.x > 0){
                if (m * a[i].speed.x + a[i].a.x <= minX) l = m;
                else r = m;
            }
            else {
                if (m * a[i].speed.x + a[i].a.x <= minX) r = m;
                else l = m;
            }
        }

        min_x = l;

        l = 0, r = 1e6;

        for (int z = 1; z <= 100; z++){
            double m = (l + r) / 2.0;
            if (a[i].speed.x > 0){
                if (m * a[i].speed.x + a[i].a.x <= maxX) l = m;
                else r = m;
            }
            else {
                if (m * a[i].speed.x + a[i].a.x <= maxX) r = m;
                else l = m;
            }
        }

        max_x = l;

        double min_y = -1, max_y = -1;

        l = 0, r = 1e6;

        for (int z = 1; z <= 100; z++){
            double m = (l + r) / 2.0;
            if (a[i].speed.y > 0){
                if (m * a[i].speed.y + a[i].a.y <= minY) l = m;
                else r = m;
            }
            else {
                if (m * a[i].speed.y + a[i].a.y <= minY) r = m;
                else l = m;
            }
        }

        min_y = l;

        l = 0, r = 1e6;

        for (int z = 1; z <= 100; z++){
            double m = (l + r) / 2.0;
            if (a[i].speed.y > 0){
                if (m * a[i].speed.y + a[i].a.y <= maxY) l = m;
                else r = m;
            }
            else {
                if (m * a[i].speed.y + a[i].a.y <= maxY) r = m;
                else l = m;
            }
        }

        max_y = l;

        //

        //cout << min_x << ' ' << max_x << "     " << min_y << ' ' << max_y << endl;

        if (max_y < min_y) swap(max_y, min_y);

        if (max_x < min_x) swap(max_x, min_x);

        double min_time = max(min_x, min_y);
        double max_time = min(max_x, max_y);

        if (min_time > max_time + 0.00001){
            cout << -1;
            return 0;
        }

        if (min_time < 0.0000001){
            cout << -1;
            return 0;
        }

        sl.push_back({min_time, 1});
        sl.push_back({max_time + 0.00001, -1});
    }

    int status = 0;

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

    for (int i = 0; i < sl.size(); i++){
        status += sl[i].second;
        if (status == n){
            cout << sl[i].first;
            return 0;
        }
    }

    cout << -1;
}


#include <bits/stdc++.h>

using namespace std;

void Draganov47(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cout << fixed << setprecision(10);
}

struct pt {
    double x, y;
};

struct vc {
    double x, y;
};

vc gv(pt a, pt b) {
    return {b.x - a.x, b.y - a.y};
}

double ks(vc a, vc b) {
    return (a.x * b.y) - (a.y * b.x);
}

double sc(vc a, vc b) {
    return (a.x + b.x) - (a.y + b.y);
}

const int MAX = 1e5 + 47;

struct mause{
    pt a, b, speed;
};

int n;

pt f, s;

mause a[MAX];

int main(){
    Draganov47();

    cin >> n;

    cin >> f.x >> f.y >> s.x >> s.y;

    double maxX = max(f.x, s.x);
    double minX = min(f.x, s.x);
    double maxY = max(f.y, s.y);
    double minY = min(f.y, s.y);

    vector < pair <double, int> > sl;

    for (int i = 1; i <= n; i++) cin >> a[i].a.x >> a[i].a.y >> a[i].speed.x >> a[i].speed.y;
    for (int i = 1; i <= n; i++){

        double min_x = -1, max_x = -1;

        //

        double l = 0, r = 1e6;

        for (int z = 1; z <= 100; z++){
            double m = (l + r) / 2.0;
            if (a[i].speed.x > 0){
                if (m * a[i].speed.x + a[i].a.x <= minX) l = m;
                else r = m;
            }
            else {
                if (m * a[i].speed.x + a[i].a.x <= minX) r = m;
                else l = m;
            }
        }

        min_x = l;

        l = 0, r = 1e6;

        for (int z = 1; z <= 100; z++){
            double m = (l + r) / 2.0;
            if (a[i].speed.x > 0){
                if (m * a[i].speed.x + a[i].a.x <= maxX) l = m;
                else r = m;
            }
            else {
                if (m * a[i].speed.x + a[i].a.x <= maxX) r = m;
                else l = m;
            }
        }

        max_x = l;

        double min_y = -1, max_y = -1;

        l = 0, r = 1e6;

        for (int z = 1; z <= 100; z++){
            double m = (l + r) / 2.0;
            if (a[i].speed.y > 0){
                if (m * a[i].speed.y + a[i].a.y <= minY) l = m;
                else r = m;
            }
            else {
                if (m * a[i].speed.y + a[i].a.y <= minY) r = m;
                else l = m;
            }
        }

        min_y = l;

        l = 0, r = 1e6;

        for (int z = 1; z <= 100; z++){
            double m = (l + r) / 2.0;
            if (a[i].speed.y > 0){
                if (m * a[i].speed.y + a[i].a.y <= maxY) l = m;
                else r = m;
            }
            else {
                if (m * a[i].speed.y + a[i].a.y <= maxY) r = m;
                else l = m;
            }
        }

        max_y = l;

        //

        //cout << min_x << ' ' << max_x << "     " << min_y << ' ' << max_y << endl;

        if (max_y < min_y) swap(max_y, min_y);

        if (max_x < min_x) swap(max_x, min_x);

        double min_time = max(min_x, min_y);
        double max_time = min(max_x, max_y);

        if (min_time + 0.00001 > max_time){
            cout << -1;
            return 0;
        }

        sl.push_back({min_time, 1});
        sl.push_back({max_time + 0.00001, -1});
    }

    int status = 0;

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

    for (int i = 0; i < sl.size(); i++){
        status += sl[i].second;
        if (status == n){
            cout << sl[i].first;
            return 0;
        }
    }

    cout << -1;
}


#include <bits/stdc++.h>

using namespace std;

void Draganov47(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cout << fixed << setprecision(10);
}

struct pt {
    double x, y;
};

struct vc {
    double x, y;
};

vc gv(pt a, pt b) {
    return {b.x - a.x, b.y - a.y};
}

double ks(vc a, vc b) {
    return (a.x * b.y) - (a.y * b.x);
}

double sc(vc a, vc b) {
    return (a.x + b.x) - (a.y + b.y);
}

const int MAX = 1e5 + 47;

struct mause{
    pt a, b, speed;
};

int n;

pt f, s;

mause a[MAX];

void valid(mause a){
    a.b.x = a.a.x + a.speed.x;
    a.b.y = a.a.y + a.speed.y;
    bool f11, f22, f33, f44;
    pt f1, s1;
    f1.x = f.x;
    f1.y = s.y;
    s1.x = s.x;
    s1.y = f.y;
    f11 = (ks(gv(a.a, a.b), gv(f, f1)) == 0);
    f22 = (ks(gv(a.a, a.b), gv(s, f1)) == 0);
    f33 = (ks(gv(a.a, a.b), gv(s1, f)) == 0);
    f44 = (ks(gv(a.a, a.b), gv(s1, s)) == 0);
    if (f11 || f22 || f33 || f44){
        cout << -1;
        exit(0);
    }
}

int main(){
    Draganov47();

    cin >> n;

    cin >> f.x >> f.y >> s.x >> s.y;

    double maxX = max(f.x, s.x);
    double minX = min(f.x, s.x);
    double maxY = max(f.y, s.y);
    double minY = min(f.y, s.y);

    vector < pair <double, int> > sl;

    for (int i = 1; i <= n; i++) cin >> a[i].a.x >> a[i].a.y >> a[i].speed.x >> a[i].speed.y, valid(a[i]);
    for (int i = 1; i <= n; i++){

        double min_x = -1, max_x = -1;

        //

        double l = 0, r = 1e6;

        for (int z = 1; z <= 100; z++){
            double m = (l + r) / 2.0;
            if (a[i].speed.x > 0){
                if (m * a[i].speed.x + a[i].a.x <= minX) l = m;
                else r = m;
            }
            else {
                if (m * a[i].speed.x + a[i].a.x <= minX) r = m;
                else l = m;
            }
        }

        min_x = l;

        l = 0, r = 1e6;

        for (int z = 1; z <= 100; z++){
            double m = (l + r) / 2.0;
            if (a[i].speed.x > 0){
                if (m * a[i].speed.x + a[i].a.x <= maxX) l = m;
                else r = m;
            }
            else {
                if (m * a[i].speed.x + a[i].a.x <= maxX) r = m;
                else l = m;
            }
        }

        max_x = l;

        double min_y = -1, max_y = -1;

        l = 0, r = 1e6;

        for (int z = 1; z <= 100; z++){
            double m = (l + r) / 2.0;
            if (a[i].speed.y > 0){
                if (m * a[i].speed.y + a[i].a.y <= minY) l = m;
                else r = m;
            }
            else {
                if (m * a[i].speed.y + a[i].a.y <= minY) r = m;
                else l = m;
            }
        }

        min_y = l;

        l = 0, r = 1e6;

        for (int z = 1; z <= 100; z++){
            double m = (l + r) / 2.0;
            if (a[i].speed.y > 0){
                if (m * a[i].speed.y + a[i].a.y <= maxY) l = m;
                else r = m;
            }
            else {
                if (m * a[i].speed.y + a[i].a.y <= maxY) r = m;
                else l = m;
            }
        }

        max_y = l;

        //

        if (max_y < min_y) swap(max_y, min_y);

        if (max_x < min_x) swap(max_x, min_x);

        double min_time = max(min_x, min_y);
        double max_time = min(max_x, max_y);

        if (min_time > max_time + 0.00001){
            cout << -1;
            return 0;
        }

        sl.push_back({min_time, 1});
        sl.push_back({max_time + 0.00001, -1});
    }

    int status = 0;

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

    for (int i = 0; i < sl.size(); i++){
        status += sl[i].second;
        if (status == n){
            cout << sl[i].first;
            return 0;
        }
    }

    cout << -1;
}


#include <bits/stdc++.h>

using namespace std;

void Draganov47(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cout << fixed << setprecision(10);
}

struct pt {
    double x, y;
};

struct vc {
    double x, y;
};

vc gv(pt a, pt b) {
    return {b.x - a.x, b.y - a.y};
}

double ks(vc a, vc b) {
    return (a.x * b.y) - (a.y * b.x);
}

double sc(vc a, vc b) {
    return (a.x + b.x) - (a.y + b.y);
}

const int MAX = 1e5 + 47;

struct mause{
    pt a, b, speed;
};

int n;

pt f, s;

mause a[MAX];

int main(){
    Draganov47();

    cin >> n;

    cin >> f.x >> f.y >> s.x >> s.y;

    double maxX = max(f.x, s.x);
    double minX = min(f.x, s.x);
    double maxY = max(f.y, s.y);
    double minY = min(f.y, s.y);

    vector < pair <double, int> > sl;

    for (int i = 1; i <= n; i++) cin >> a[i].a.x >> a[i].a.y >> a[i].speed.x >> a[i].speed.y;
    for (int i = 1; i <= n; i++){

        double min_x = -1, max_x = -1;

        //

        double l = 0, r = 1e6;

        for (int z = 1; z <= 100; z++){
            double m = (l + r) / 2.0;
            if (a[i].speed.x > 0){
                if (m * a[i].speed.x + a[i].a.x <= minX) l = m;
                else r = m;
            }
            else {
                if (m * a[i].speed.x + a[i].a.x <= minX) r = m;
                else l = m;
            }
        }

        min_x = l;

        l = 0, r = 1e6;

        for (int z = 1; z <= 100; z++){
            double m = (l + r) / 2.0;
            if (a[i].speed.x > 0){
                if (m * a[i].speed.x + a[i].a.x <= maxX) l = m;
                else r = m;
            }
            else {
                if (m * a[i].speed.x + a[i].a.x <= maxX) r = m;
                else l = m;
            }
        }

        max_x = l;

        double min_y = -1, max_y = -1;

        l = 0, r = 1e6;

        for (int z = 1; z <= 100; z++){
            double m = (l + r) / 2.0;
            if (a[i].speed.y > 0){
                if (m * a[i].speed.y + a[i].a.y <= minY) l = m;
                else r = m;
            }
            else {
                if (m * a[i].speed.y + a[i].a.y <= minY) r = m;
                else l = m;
            }
        }

        min_y = l;

        l = 0, r = 1e6;

        for (int z = 1; z <= 100; z++){
            double m = (l + r) / 2.0;
            if (a[i].speed.y > 0){
                if (m * a[i].speed.y + a[i].a.y <= maxY) l = m;
                else r = m;
            }
            else {
                if (m * a[i].speed.y + a[i].a.y <= maxY) r = m;
                else l = m;
            }
        }

        max_y = l;

        //

        //cout << min_x << ' ' << max_x << "     " << min_y << ' ' << max_y << endl;

        if (max_y < min_y) swap(max_y, min_y);

        if (max_x < min_x) swap(max_x, min_x);

        double min_time = max(min_x, min_y);
        double max_time = min(max_x, max_y);

        if (min_time + 0.00001 > max_time){
            cout << -1;
            return 0;
        }

        sl.push_back({min_time - 0.00001, 1});
        sl.push_back({max_time + 0.00001, -1});
    }

    int status = 0;

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

    for (int i = 0; i < sl.size(); i++){
        status += sl[i].second;
        if (status == n){
            cout << sl[i].first;
            return 0;
        }
    }

    cout << -1;
}


#include <bits/stdc++.h>

using namespace std;

void Draganov47(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cout << fixed << setprecision(10);
}

struct pt {
    double x, y;
};

struct vc {
    double x, y;
};

vc gv(pt a, pt b) {
    return {b.x - a.x, b.y - a.y};
}

double ks(vc a, vc b) {
    return (a.x * b.y) - (a.y * b.x);
}

double sc(vc a, vc b) {
    return (a.x + b.x) - (a.y + b.y);
}

const int MAX = 1e5 + 47;

struct mause{
    pt a, b, speed;
};

int n;

pt f, s;

mause a[MAX];

int main(){
    Draganov47();

    cin >> n;

    cin >> f.x >> f.y >> s.x >> s.y;

    double maxX = max(f.x, s.x);
    double minX = min(f.x, s.x);
    double maxY = max(f.y, s.y);
    double minY = min(f.y, s.y);

    vector < pair <double, int> > sl;

    for (int i = 1; i <= n; i++) cin >> a[i].a.x >> a[i].a.y >> a[i].speed.x >> a[i].speed.y;
    for (int i = 1; i <= n; i++){

        double min_x = -1, max_x = -1;

        //

        double l = 0, r = 1e6;

        for (int z = 1; z <= 100; z++){
            double m = (l + r) / 2.0;
            if (a[i].speed.x > 0){
                if (m * a[i].speed.x + a[i].a.x <= minX) l = m;
                else r = m;
            }
            else {
                if (m * a[i].speed.x + a[i].a.x <= minX) r = m;
                else l = m;
            }
        }

        min_x = l;

        l = 0, r = 1e6;

        for (int z = 1; z <= 100; z++){
            double m = (l + r) / 2.0;
            if (a[i].speed.x > 0){
                if (m * a[i].speed.x + a[i].a.x <= maxX) l = m;
                else r = m;
            }
            else {
                if (m * a[i].speed.x + a[i].a.x <= maxX) r = m;
                else l = m;
            }
        }

        max_x = l;

        double min_y = -1, max_y = -1;

        l = 0, r = 1e6;

        for (int z = 1; z <= 100; z++){
            double m = (l + r) / 2.0;
            if (a[i].speed.y > 0){
                if (m * a[i].speed.y + a[i].a.y <= minY) l = m;
                else r = m;
            }
            else {
                if (m * a[i].speed.y + a[i].a.y <= minY) r = m;
                else l = m;
            }
        }

        min_y = l;

        l = 0, r = 1e6;

        for (int z = 1; z <= 100; z++){
            double m = (l + r) / 2.0;
            if (a[i].speed.y > 0){
                if (m * a[i].speed.y + a[i].a.y <= maxY) l = m;
                else r = m;
            }
            else {
                if (m * a[i].speed.y + a[i].a.y <= maxY) r = m;
                else l = m;
            }
        }

        max_y = l;

        if (a[i].a.x == min_x && a[i].speed.x == 0){
            cout << -1;
            return 0;
        }

        if (a[i].a.x == max_x && a[i].speed.x == 0){
            cout << -1;
            return 0;
        }

        if (a[i].a.y == min_y && a[i].speed.y == 0){
            cout << -1;
            return 0;
        }

        if (a[i].a.y == max_y && a[i].speed.y == 0){
            cout << -1;
            return 0;
        }

        //

        if (max_y < min_y) swap(max_y, min_y);

        if (max_x < min_x) swap(max_x, min_x);

        double min_time = max(min_x, min_y);
        double max_time = min(max_x, max_y);

        if (min_time > max_time + 0.00001){
            cout << -1;
            return 0;
        }

        sl.push_back({min_time, 1});
        sl.push_back({max_time + 0.00001, -1});
    }

    int status = 0;

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

    for (int i = 0; i < sl.size(); i++){
        status += sl[i].second;
        if (status == n){
            cout << sl[i].first;
            return 0;
        }
    }

    cout << -1;
}