#include <iostream>
using namespace std;

int main()
{
    int t, n;
    cin >> t;
    for (int i = 0; i < t; i++)
    {
        cin >> n;
        int ans = 0;
        for (int j = 1; j <= n/2; j++)
        {
            ans += 8 * j * j;
        }
        cout << ans << endl;
    }
    return 0;
}


#include <iostream>
using namespace std;

int main()
{
    long long int t, n;
    cin >> t;
    for (int i = 0; i < t; i++)
    {
        cin >> n;
        long long int ans = 0;
        for (long long int j = 1; j <= n/2; j++)
        {
            ans += 8 * j * j;
        }
        cout << ans << endl;
    }
    return 0;
}


#include <iostream>

using namespace std;

int main()
{
	long long int boardSize, test_cases, stepsCount;

	cin >> test_cases;

	for (int k = 0; k < test_cases; k++)
	{
		stepsCount = 0;
		cin >> boardSize;
		for (int i = 0; i <= boardSize / 2; i++)
		{
			stepsCount += static_cast<long long int>(8) * i * i;
		}
		cout << stepsCount << endl;
	}
	return 0;
}


#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <cstdio>
#include <string>
#include <cmath>
#include <queue>
#include <tuple>
#include <bitset>
#include <cassert>
#include <chrono>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <random>
#include <set>
#include <stack>

//#include <bits/stdc++.h>
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define repr(i, n) for (int i = (n) - 1; i >= 0; i--)
#define FOR(i,i0,n) for(int (i)=(i0);(i)<(n);(i)++)
#define FORR(i,i0,n) for(int (i)=(n)-1; (i)>=(i0);(i)--)
#define SORT(x) sort(x.begin(),x.end())
#define SORTR(x) sort(x.begin(),x.end(),greater<int>())
#define rn return
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
#include <time.h>
typedef std::pair<int,int> pii;
using namespace std;
using ll = long long;

void solve(){
    int n;
    cin >> n;
    ll ans = 0;
    ll d = 1;

    while(d <= n/2){
        ans += (8*d*d);
        d++;
    }
    cout << ans;

}

int main(){
    int T;
    cin >> T;
    for(int t = 1; t <= T; t++){
        solve();
        cout << endl;
    }
}


#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <cstdio>
#include <string>
#include <cmath>
#include <queue>
#include <tuple>
#include <bitset>
#include <cassert>
#include <chrono>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <random>
#include <set>
#include <stack>

//#include <bits/stdc++.h>
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define repr(i, n) for (int i = (n) - 1; i >= 0; i--)
#define FOR(i,i0,n) for(int (i)=(i0);(i)<(n);(i)++)
#define FORR(i,i0,n) for(int (i)=(n)-1; (i)>=(i0);(i)--)
#define SORT(x) sort(x.begin(),x.end())
#define SORTR(x) sort(x.begin(),x.end(),greater<int>())
#define rn return
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
#include <time.h>
typedef std::pair<int,int> pii;
using namespace std;
using ll = long long;

void solve(){
    int n;
    cin >> n;
    ll ans = 0;
    int d = 1;
    while(d < n){
        ans+= 8*d;
        d++;
    }
    cout << d;

}

int main(){
    int T;
    cin >> T;
    for(int t = 1; t <= T; t++){
        solve();
        cout << endl;
    }
}


#define _CRT_SECURE_NO_WARNINGS
#include <numeric>
#include <functional>
#include <iostream>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <string>
#include <fstream>

using namespace std;

long long gcd(long long a, long long b) {
	while (b) {
		a %= b;
		swap(a, b);
	}
	return a;
}

long long lcm(long long  a, long long  b) {
	return a * b / gcd(a, b);
}

int mod = 1000000007;

inline int add(int a, int b) {
	int ret = a + b;
	if (ret >= mod)
		ret -= mod;
	return ret;
}

const double pi = 3.14159265358979323846;

int a[30], b[30];
int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int t;
	long long n;
	cin >> t;
	while (t--) {
		cin >> n;
		cout << n * (n - 1)*(n + 1) / 3 << '\n';
	}
	/*system("pause");*/
	return 0;
}


#include<iostream>
#include <bits/stdc++. h>
using namespace std;
int main(){
int t,n;
cin>>t;
while(t--){
    cin>>n;
    cout<<(1LL*n*(n+1)*(n-1))/3<<endl;
}
}


#include<iostream>
using namespace std;
int main(){
int t,n;
cin>>t;
while(t--){
    cin>>n;
    cout<<(1LL*n*(n+1)*(n-1))/3<<endl;
}
}


#include<stdio.h>
int main()
{
	int t, n, i, num = 0;
	scanf_s("%d", &t);
	while (t--)
	{
		scanf_s("%d", &n);
				for (i = 1; i <= (n-1)/2; i++)
				{
					num = num + i * i * 8;
}

				printf("%d\n", num);
	}
	return 0;
}


#include<stdio.h>

int main()
{
long t, n, num = 0;
	int i = 0;
	scanf_s("%d", &t);
	while (t--)
	{
		scanf_s("%ld", &n);

		for (i = 0; i <= (n - 1) / 2; i++)
		{
			num = num + i * i * 8;
		}

	printf("%ld\n", num);
}
	return 0;
}


#include <stdio.h>
#define LL long long
int main() {
	int t;
	LL n, sum, a, c, d;
	scanf("%d", &t);
	while (t--) {
		sum = 0, c = 0, d = 0;
		scanf("%lld", &n);
		a = (n - 1) / 2;
		sum += (1 + a) * a / 2 * 4;//蓝色部分计算
		sum += (1 + a) * a / 2 * 4;//黄色部分计算
		for (LL i = a; i >= 2; i--)//白色部分计算
			c += i, d += c;
		sum += d * 8;//白色部分计算
		printf("%lld\n", sum);
	}
	return 0;
}


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

ll n;

int main()
{
	int t;
	scanf("%d",&t);
	while(t--)
	{
		scanf("%lld",&n);
		ll ans=0;
		ll num=n/2;
		for(int i=n;num;i-=2,num--) ans+=(num*(ll)(i*4-4));
		cout<<ans<<endl;
	}
	return 0;
}


#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <queue>
#include <algorithm>
#include <set>
#include <functional>
#include <numeric>
#include <iterator>
#include <iomanip>
#define ll long long
const int mod = 1e9 + 7;
using namespace std;

int main()
{
	int t;
	cin >> t;
	while (t--)
	{
		ll n;
		cin >> n;
		n = (n - 1) / 2;
		cout << 8 * (n * (n + 1) * (2 * n + 1) / 6) << endl;
	}
	return 0;
}


#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <queue>
#include <algorithm>
#include <set>
#include <functional>
#include <numeric>
#include <iterator>
#include <iomanip>
#define ll long long
const int mod = 1e9 + 7;
using namespace std;

int main()
{
	int t;
	cin >> t;
	while (t--)
	{
		ll n;
		cin >> n;
		n = (n - 1) / 2;
		cout << (n == 1 ? 0 : 8 * (n * (n + 1) * (2 * n + 1) / 6)) << endl;
	}
	return 0;
}


#include <iostream>
#include <string.h>
#include <math.h>
using namespace std;
int main()
{
    static long long no;
    cin>>no;
    while(no--)
    {
       long long n,sum=0,j=3,ans=0;
       cin>>n;
       for(int i=1;j<=n  ;i++,j++,j++)
           ans+=(i*(j-1)*4);
        cout<<ans<<endl;
    }
	return 0;
}


    #include <iostream>
    #include <algorithm>
    #include <minmax.h>
    #include <vector>
    #include <math.h>

    #define ll long long
    #define vint vector<int>

    using namespace std;

    void solve() {
        ll n, mid, ans = 0;
        cin >> n;
        mid = floor(n/2);
        while (mid > 0 && n > 1) {
            ans += (4 * n - 4) * mid;
            n -= 2;
            --mid;
        }
        cout << ans << "\n";
    }

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

        int t;
        cin >> t;
        while (t--) {
            solve();
        }
    }


#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <climits>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <string>
#include <list>
#include <ctime>
#include <complex>
#include <bitset>
#include <tuple>

#define IOS ios::sync_with_stdio(false);cin.tie(0)
#define all(x) x.begin(), x.end()
#define ff first
#define ss second

using namespace std;
using llong = long long;

void solve()
{
	llong n;
	cin >> n;
	llong sum = 0;
	for (long long i = 1; i <= n / 2; i++)
	{
		sum += i * 8 * i;
	}
	cout << sum <<"\n";
}
int main()
{
	IOS;

	int tt;
	cin >> tt;
	while (tt--) solve();

	return 0;
}


#include<iostream>
#include<cmath>

using namespace std;

int main(){
    unsigned long long int a,n,t;
    cin>>t;
    for(int i=1;i<=t;i++){
        cin>>n;
        a=n*(n*n-1);
        cout<<a/3<<endl;
    }
}


#include <functional>
#include <algorithm>
#include <iostream>
#include <fstream>
#include <sstream>
#include <iomanip>
#include <numeric>
#include <cstring>
#include <cassert>
#include <cstdio>
#include <string>
#include <vector>
#include <bitset>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
using namespace std;

// C. Board Moves
// https://codeforces.com/problemset/problem/1353/C

// (4*3-4) + 2*(4*5 - 4) + 3*(4*7 - 4) + ...
// 1*4*2 + 2*4*4 + 3*4*6 + 4*4*8 ...
// 4 sum i=1^p i * 2i
// 8 sum i=1^p i^2 = 8 p (p+1) (2p + 1) / 6

void solve(int n)
{
	int p = n/2;
	long long ans = 1LL*4*p*(p+1)*(2*p+1)/3;
	cout << ans << endl;
}

int main(int argc, char const *argv[])
{
#ifndef ONLINE_JUDGE
	ifstream in("inputC.txt");
	cin.rdbuf(in.rdbuf()); //redirect cin to input.txt!
	ofstream out("outC.txt");
	cout.rdbuf(out.rdbuf()); //redirect cout to out.txt!
#endif

	int t;
	cin >> t;
	while (t--)
	{
		int n;
		cin >> n;
		solve(n);
	}
	return 0;
}


#include <iostream>
#define ll long long

using namespace std;

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

	ll t,n;
	cin >> t;

	while (t--)
	{
		ll res = 0;
		ll j = 1;
		cin >> n;

		for (ll i = 1; i < n ; i += 2)
		{
			res += ((i + 2) * (i + 2) - i*i)*j;
			j++;
		}

		cout << res << "\n";

	}

	return 0;
}


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

int main()
{
	int t,a;
	 long long  s;
	scanf("%d",&t);
	while(t--){
	scanf("%d",&a);
	s=0;
	for(int i=1;i<=a/2;i++){
		s=s+(long long)((2*i+1)*(2*i+1)-(2*i-1)*(2*i-1))*(i);

	}
	printf("%lld\n",s);
	}
return 0;
}


#include<stdio.h>
#include<string.h>
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int t;
	 long long  a,s;
	scanf("%d",&t);
	while(t--){

	scanf("%lld",&a);
	s=0;
	for(int i=1;i<=a/2;i++){
		s=s+((2*i+1)*(2*i+1)-(2*i-1)*(2*i-1))*(i);

	}
	printf("%lld",s);
	}
return 0;
}


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

int main()
{
	int t;
	 long long  a,s;
	scanf("%d",&t);
	while(t--){

	scanf("%lld",&a);
	s=0;
	for(int i=1;i<=a/2;i++){
		s=s+((2*i+1)*(2*i+1)-(2*i-1)*(2*i-1))*(i);

	}
	printf("%lld\n",s);
	}
return 0;
}


#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cctype>
#include <functional>
#include <ctime>
#include <cmath>
#include <limits>
#include <numeric>
#include <type_traits>
#include <iomanip>
#include <float.h>
#include <math.h>
using namespace std;
using ll = long long;

unsigned euclidean_gcd(unsigned a, unsigned b) {
    if (a < b) return euclidean_gcd(b, a);
    unsigned r;
    while ((r = a % b)) {
        a = b;
        b = r;
    }
    return b;
}

class UnionFind {
public:
    vector <ll> par;
    vector <ll> siz;
    UnionFind(ll sz_) : par(sz_), siz(sz_, 1LL) {
        for (ll i = 0; i < sz_; ++i) par[i] = i;
    }
    void init(ll sz_) {
        par.resize(sz_);
        siz.assign(sz_, 1LL);
        for (ll i = 0; i < sz_; ++i) par[i] = i;
    }
    ll root(ll x) {
        while (par[x] != x) {
            x = par[x] = par[par[x]];
        }
        return x;
    }
    bool merge(ll x, ll y) {
        x = root(x);
        y = root(y);
        if (x == y) return false;
        if (siz[x] < siz[y]) swap(x, y);
        siz[x] += siz[y];
        par[y] = x;
        return true;
    }

    bool issame(ll x, ll y) {
        return root(x) == root(y);
    }

    ll size(ll x) {
        return siz[root(x)];
    }
};

long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

long long modinv(long long a, long long mod) {
    return modpow(a, mod - 2, mod);
}

int main() {
    int t;
    cin >> t;
    for (int i = 0; i < t; i++) {
        ll a;
        cin >> a;
        ll ans = 0;
        for (ll i = 0; i < (a+1)/2; i++) {
            ans += i * i * 8;
        }
        cout << ans << endl;
    }
}


#include <iostream>
#include <algorithm>
#include <vector>
#include <iterator>
#include <utility>
#include <set>
#include <deque>
#include <list>

using namespace std;

int main()
{
    int t;
    cin >> t;
    while (t--)
    {
        int n;
        cin >> n;
        long long ans = 0;
        long long g = 1;
        long long k = 8;
        for (int i = 0; i < n / 2; ++i)
        {
            ans += g * k;
            ++g;
            k += 8;
        }
        cout << ans << endl;
    }
    return 0;
}


#include <iostream>
#include <algorithm>
#include <vector>
#include <iterator>
#include <utility>
#include <set>
#include <deque>
#include <list>

using namespace std;

int main()
{
    int t;
    cin >> t;
    while (t--)
    {
        int n;
        cin >> n;
        unsigned long long ans = 0;
        int g = 1;
        int k = 8;
        for (int i = 0; i < n / 2; ++i)
        {
            ans += g * k;
            ++g;
            k += 8;
        }
        cout << ans << endl;
    }
    return 0;
}


#include<iostream>
using namespace std;

int main()
{
    int t;
    long n;

    cin>>t;

    while(t--)
    {
        cin>>n;

        n = n/2;

        cout<<8*((n*(n + 1)*(2*n + 1)) / 6)<<endl;

    }

    return 0;
}


#include<iostream>
using namespace std;

int main()
{
    int t;
    long n;

    cin>>t;

    while(t--)
    {
        cin>>n;
        cout<<5*n<<endl;
    }

    return 0;
}


#include<iostream>
using namespace std;

int main()
{
    int t;
    long long n;

    cin>>t;

    while(t--)
    {
        cin>>n;

        n = n/2;

        cout<<8*((n*(n + 1)*(2*n + 1)) / 6)<<endl;

    }

    return 0;
}


#include<iostream>
#include<algorithm>
#define ll long long
#define INF 0x3f3f3f3f
using namespace std;
int main()
{
	std::ios::sync_with_stdio(false);
	int t;
	cin >> t;
	while (t--) {
		ll n, ans = 0;
		cin >> n;
		for (ll i = 1; i <= n / 2; i++) {
			ans += i * i * 8;
		}
		cout << ans << endl;
	}
	return 0;
}


#include<iostream>
#include<algorithm>
#include<queue>
#define ll long long
#define INF 0x3f3f3f3f
using namespace std;
struct node {
	int l, r;
	node(int l, int r) {
		this->l = l;
		this->r = r;
	}
	bool operator <(const node& a)const {
		if (l - r == a.l - a.r)return l > a.l;
		return l - r > a.l - a.r;
	}
};
int a[200005];
int main()
{
	std::ios::sync_with_stdio(false);
	int t;
	cin >> t;
	while (t--) {
		int n, k = 1;
		cin >> n;
		priority_queue<node>q;
		q.push(node(1, n));
		while (!q.empty()) {
			node now = q.top(); q.pop();
			int mid = (now.l + now.r) / 2;
			a[mid] = k++;
			if (mid > now.l)q.push(node(now.l, mid - 1));
			if (mid < now.r)q.push(node(mid + 1, now.r));
		}
		for (int i = 1; i <= n; i++) {
			cout << a[i] << " ";
		}
		cout << endl;
	}
	return 0;
}


#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
	std::ios::sync_with_stdio(false);
	int t;
	cin >> t;
	while (t--) {
		ll n, ans = 0;
		cin >> n;
		for (ll i = 1; i <= n / 2; i++) {
			ans += i * i * 8;
		}
		cout << ans << endl;
	}
	return 0;
}


#include <iostream>

int main()
{
	using namespace std;
	unsigned short int t;
	long long int ans, n, C, kl;
	cin >> t;
	while (t-- > 0)
	{
		cin >> n;
		ans = 0;
		kl = n * n - 1;
		for (C = 1; ans < kl; C++)
		{
			ans += 8 * C * C;
		}
		cout << ans << endl;
	}
	return 0;
}


#include <iostream>

int main()
{
	using namespace std;
	unsigned short int t;
	unsigned long long int ans, n, C, kl;
	cin >> t;
	while (t-- > 0)
	{
		cin >> n;
		ans = 0;
		kl = n * n - 1;
		for (C = 1; C < n / 2 + 1; C++)
		{
			ans += (long long)8 * C * C;
		}
		cout << ans << endl;
	}
	return 0;
}


using namespace std;
#include<iostream>
#include<vector>
#include<queue>
#include<map>
#include <unordered_set>
#include <set>
#include <unordered_map>
#include<stack>
#include <functional>
#include <algorithm>

#define MOD1e9 1000000007
#define INT_MAX       2147483647
#define INT_MIN     (-2147483647 - 1)
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL);
#define rep(c) for(int i = 0; i <(c); ++i)
#define rrep(n) for(int i = (n) ; i >=0 ; --i)
#define fora(i, s, c) for(int i = (s); i < (c); ++i)
#define forr(i, s, c) for(int i = (s); i > (c); --i)
#define endl "\n"
#define ret(n) return n
#define pb push_back
#define eb emplace_back
#define ff first;
#define ss second;
#define mp make_pair;
#define all(p) p.begin(),p.end()
#define mid(s,e) (s+(e-s)/2)
//Typedefs
typedef long long ll;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
typedef priority_queue<int> pqint;
typedef priority_queue<ll> pqll;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef vector<long> vl;
typedef vector<vl> vvl;
typedef vector<bool> vb;
//Testcase start
#define tcs() int testcases; cin >> testcases; while(testcases--)
//Functions
inline int twop(int n) { return 1 << n; }
template<class T> T gcd(T a, T b) { if (b == 0)return a; return gcd(b, a % b); }
template<class T> T lcm(T a, T b) { return (a * b) / gcd(a, b); }
ll ctnum(char c) { if (c == '0') return 0; else if (c == '1') return 1; else if (c == '2') return 2; else if (c == '3') return 3; else if (c == '4') return 4; else if (c == '5') return 5; else if (c == '6') return 6; else if (c == '7') return 7; else if (c == '8') return 8; else if (c == '9') return 9; }
ll power(ll n, ll exp, ll MOD)
{
	if (exp == 0)
		return 1;
	ll temp = power(n, exp / 2, MOD);
	if (exp % 2 == 0)
		return ((temp % MOD) * (temp % MOD)) % MOD;
	else
		return ((n % MOD) * (temp % MOD) * (temp % MOD)) % MOD;
}
ll mod(int x, int m)
{
	return ((x % m + m) % m);
}

int X[] = { 0,-1,-1,-1,0,1,1,1 };
int Y[] = { -1,-1,0,1,1,1,0,-1 };

bool isvalidmove(int r, int c, int x, int y)
{
	if (x < 0 || y < 0 || x >= r || y >= c)
		return false;
	return true;
}

int main()
{
	tcs()
	{
		int n;
		cin >> n;
		int r = n;
		int c = n;
		int cx = n / 2;
		ll ans = 0;
		for (ll i = n - 1; i > 0; i = i - 2)
		{
			ans = ans + (i * 4) * cx;
			--cx;
		}
		cout << ans << endl;
	}
	return 0;
}


using namespace std;
#include<iostream>
#include<vector>
#include<queue>
#include<map>
#include <unordered_set>
#include <set>
#include <unordered_map>
#include<stack>
#include <functional>
#include <algorithm>

#define MOD1e9 1000000007
#define INT_MAX       2147483647
#define INT_MIN     (-2147483647 - 1)
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL);
#define rep(c) for(int i = 0; i <(c); ++i)
#define rrep(n) for(int i = (n) ; i >=0 ; --i)
#define fora(i, s, c) for(int i = (s); i < (c); ++i)
#define forr(i, s, c) for(int i = (s); i > (c); --i)
#define endl "\n"
#define ret(n) return n
#define pb push_back
#define eb emplace_back
#define ff first;
#define ss second;
#define mp make_pair;
#define all(p) p.begin(),p.end()
#define mid(s,e) (s+(e-s)/2)
//Typedefs
typedef long long ll;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
typedef priority_queue<int> pqint;
typedef priority_queue<ll> pqll;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef vector<long> vl;
typedef vector<vl> vvl;
typedef vector<bool> vb;
//Testcase start
#define tcs() int testcases; cin >> testcases; while(testcases--)
//Functions
inline int twop(int n) { return 1 << n; }
template<class T> T gcd(T a, T b) { if (b == 0)return a; return gcd(b, a % b); }
template<class T> T lcm(T a, T b) { return (a * b) / gcd(a, b); }
ll ctnum(char c) { if (c == '0') return 0; else if (c == '1') return 1; else if (c == '2') return 2; else if (c == '3') return 3; else if (c == '4') return 4; else if (c == '5') return 5; else if (c == '6') return 6; else if (c == '7') return 7; else if (c == '8') return 8; else if (c == '9') return 9; }
ll power(ll n, ll exp, ll MOD)
{
	if (exp == 0)
		return 1;
	ll temp = power(n, exp / 2, MOD);
	if (exp % 2 == 0)
		return ((temp % MOD) * (temp % MOD)) % MOD;
	else
		return ((n % MOD) * (temp % MOD) * (temp % MOD)) % MOD;
}
ll mod(int x, int m)
{
	return ((x % m + m) % m);
}

int X[] = { 0,-1,-1,-1,0,1,1,1 };
int Y[] = { -1,-1,0,1,1,1,0,-1 };

bool isvalidmove(int r, int c, int x, int y)
{
	if (x < 0 || y < 0 || x >= r || y >= c)
		return false;
	return true;
}

ll bfsfill(int r, int c, int cx, int cy)
{
	//initialize ans array
	ll ans = 0;
	//visited
	vector<vector<bool>> visited(r, vector<bool>(c, false));
	//start bfs from cx,cy
	queue < pair<int, pair<int, int>>> Q; //of format num(filled), x , y
	Q.push({ 0,{cx,cy} });
	visited[cx][cy] = true;
	while (!Q.empty())
	{
		int d = Q.front().first;
		ans += d;
		int x = Q.front().second.first;
		int y = Q.front().second.second;
		Q.pop();
		//for all neighbours of x,y
		for (int i = 0; i < 8; ++i)
		{
			int nx = x + X[i];	//next x
			int ny = y + Y[i]; //next y
			if (isvalidmove(r, c, nx, ny) && !visited[nx][ny])
			{
				visited[nx][ny] = true;
				Q.push({ d + 1,{nx,ny} });
			}

		}
	}
	return ans;
}

int main()
{
	tcs()
	{
		int n;
		cin >> n;
		int r = n;
		int c = n;
		int cx = n / 2;
		int cy = n / 2;
		auto ans = bfsfill(r, c, cx, cy);
		cout << ans << endl;
	}
	return 0;
}


using namespace std;
#include<iostream>
#include<vector>
#include<queue>
#include<map>
#include <unordered_set>
#include <set>
#include <unordered_map>
#include<stack>
#include <functional>
#include <algorithm>

#define MOD1e9 1000000007
#define INT_MAX       2147483647
#define INT_MIN     (-2147483647 - 1)
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL);
#define rep(c) for(int i = 0; i <(c); ++i)
#define rrep(n) for(int i = (n) ; i >=0 ; --i)
#define fora(i, s, c) for(int i = (s); i < (c); ++i)
#define forr(i, s, c) for(int i = (s); i > (c); --i)
#define endl "\n"
#define ret(n) return n
#define pb push_back
#define eb emplace_back
#define ff first;
#define ss second;
#define mp make_pair;
#define all(p) p.begin(),p.end()
#define mid(s,e) (s+(e-s)/2)
//Typedefs
typedef long long ll;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
typedef priority_queue<int> pqint;
typedef priority_queue<ll> pqll;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef vector<long> vl;
typedef vector<vl> vvl;
typedef vector<bool> vb;
//Testcase start
#define tcs() int testcases; cin >> testcases; while(testcases--)
//Functions
inline int twop(int n) { return 1 << n; }
template<class T> T gcd(T a, T b) { if (b == 0)return a; return gcd(b, a % b); }
template<class T> T lcm(T a, T b) { return (a * b) / gcd(a, b); }
ll ctnum(char c) { if (c == '0') return 0; else if (c == '1') return 1; else if (c == '2') return 2; else if (c == '3') return 3; else if (c == '4') return 4; else if (c == '5') return 5; else if (c == '6') return 6; else if (c == '7') return 7; else if (c == '8') return 8; else if (c == '9') return 9; }
ll power(ll n, ll exp, ll MOD)
{
	if (exp == 0)
		return 1;
	ll temp = power(n, exp / 2, MOD);
	if (exp % 2 == 0)
		return ((temp % MOD) * (temp % MOD)) % MOD;
	else
		return ((n % MOD) * (temp % MOD) * (temp % MOD)) % MOD;
}
ll mod(int x, int m)
{
	return ((x % m + m) % m);
}

int X[] = { 0,-1,-1,-1,0,1,1,1 };
int Y[] = { -1,-1,0,1,1,1,0,-1 };

bool isvalidmove(int r, int c, int x, int y)
{
	if (x < 0 || y < 0 || x >= r || y >= c)
		return false;
	return true;
}

vvi bfsfill(int r, int c, int cx, int cy)
{
	//initialize ans array
	vvi ans(r, vi(c));
	//visited
	vector<vector<bool>> visited(r, vector<bool>(c, false));
	//start bfs from cx,cy
	queue < pair<int, pair<int, int>>> Q; //of format num(filled), x , y
	ans[cx][cy] = 0;
	Q.push({ 0,{cx,cy} });
	visited[cx][cy] = true;
	while (!Q.empty())
	{
		int d = Q.front().first;
		int x = Q.front().second.first;
		int y = Q.front().second.second;
		Q.pop();
		//for all neighbours of x,y
		for (int i = 0; i < 8; ++i)
		{
			int nx = x + X[i];	//next x
			int ny = y + Y[i]; //next y
			if (isvalidmove(r, c, nx, ny) && !visited[nx][ny])
			{
				visited[nx][ny] = true;
				ans[nx][ny] = d + 1;
				Q.push({ d + 1,{nx,ny} });
			}

		}

	}
	return ans;
}

int main()
{
	tcs()
	{
		int n;
		cin >> n;
		int r = n;
		int c = n;
		int cx = n / 2;
		int cy = n / 2;
		auto ans = bfsfill(r, c, cx, cy);
		ll sum = 0;
		fora(i, 0, n)
		{
			fora(j, 0, n)
			{
				sum += ans[i][j];
			}
		}
		cout << sum << endl;
	}
	return 0;
}


#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <string>
#include <unordered_map>
#include <set>
#include <vector>

using namespace std;
typedef int64_t i;
#define endl '\n'
int main()
{
    i t;
    cin >> t;
    while (t--)
    {
        i n;
        cin >> n;
        i k = n / 2;
        cout << k*n*n-k*(4*k*k-1)/3<< endl;
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define forn(i, n) for(int i = 1; i <= n; ++ i)
#define for1(i, n) for(int i = 1; i <= n; ++ i)
#define IO ios::sync_with_stdio(false)

int main()
{
	IO;
	int T; cin >> T; while(T --) {
	int n; cin >> n;
	-- n;
	ll ans = 0, sum = 0;
	n >>= 1;
	cout << n<< endl;
	for1(i, n) {
		sum += 8;
		ans += sum * i;
  	}
  	cout << ans << '\n';
	}
	return 0;
}


#include<iostream>
using namespace std;
#define ll long long
#define forn(i, n) for(int i = 1; i <= n; ++ i)
#define for1(i, n) for(int i = 1; i <= n; ++ i)
#define IO ios::sync_with_stdio(false)

int main()
{
	IO;
	int T; cin >> T; while(T --) {
	int n; cin >> n;
	-- n;
	ll ans = 0, sum = 0;
	n >>= 1;
	for1(i, n) {
		sum += 8;
		ans += sum * i;
  	}
  	cout << ans << '\n';
	}
	return 0;
}


#include <iostream>
using namespace std;
typedef long long ll;

# include <cstdio>
# include <iostream>
# include <cstring>
# include <algorithm>
# include <cmath>

using namespace std;

# define FOR(i, a, b) for(int i = a; i <= b; i++)
# define _FOR(i, a, b) for(int i = a; i >= b; i--)

struct BigInt
{
    static const int M = 1000;
    int num[M + 10], len;

    BigInt() { clean(); }

	void clean(){
    	memset(num, 0, sizeof(num));
    	len = 1;
	}

    void read(){
    	char str[M + 10];
        scanf("%s", str);
        len = strlen(str);
        FOR(i, 1, len)
            num[i] = str[len - i] - '0';
    }

    void write(){
        _FOR(i, len, 1)
            printf("%d", num[i]);
        puts("");
    }

    void itoBig(int x){
    	clean();
    	while(x != 0){
    		num[len++] = x % 10;
    		x /= 10;
		}
		if(len != 1) len--;
	}

    bool operator < (const BigInt &cmp) const {
        if(len != cmp.len) return len < cmp.len;
        _FOR(i, len, 1)
            if(num[i] != cmp.num[i]) return num[i] < cmp.num[i];
        return false;
    }

    bool operator > (const BigInt &cmp) const { return cmp < *this; }
	bool operator <= (const BigInt &cmp) const { return !(cmp < *this); }
	bool operator != (const BigInt &cmp) const { return cmp < *this || *this < cmp; }
	bool operator == (const BigInt &cmp) const { return !(cmp < *this || *this < cmp); }

    BigInt operator + (const BigInt &A) const {
        BigInt S;
        S.len = max(len, A.len);
        FOR(i, 1, S.len){
            S.num[i] += num[i] + A.num[i];
            if(S.num[i] >= 10){
                S.num[i] -= 10;
                S.num[i + 1]++;
            }
        }
        while(S.num[S.len + 1]) S.len++;
        return S;
    }

    BigInt operator - (const BigInt &A) const {
        BigInt S;
        S.len = max(len, A.len);
        FOR(i, 1, S.len){
            S.num[i] += num[i] - A.num[i];
            if(S.num[i] < 0){
                S.num[i] += 10;
                S.num[i + 1]--;
            }
        }
        while(!S.num[S.len] && S.len > 1) S.len--;
        return S;
    }

    BigInt operator * (const BigInt &A) const {
        BigInt S;
        if((A.len == 1 && A.num[1] == 0) || (len == 1 && num[1] == 0)) return S;
        S.len = A.len + len - 1;
        FOR(i, 1, len)
            FOR(j, 1, A.len){
                S.num[i + j - 1] += num[i] * A.num[j];
                S.num[i + j] += S.num[i + j - 1] / 10;
                S.num[i + j - 1] %= 10;
            }
        while(S.num[S.len + 1]) S.len++;
        return S;
    }
};

int main(){
    std::ios::sync_with_stdio(false);
    int t;
    BigInt n, ans, i, two;
    two.itoBig(2);
    cin >> t;
    while(t--){
        n.read();
        ans.itoBig(0);
        i.itoBig(0);
        for (;i < n; i = i + two){
            ans = ans + i * i * two;
        }
        ans.write();
    }
    return 0;
}


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

int main() {
	int t;
	cin >> t;
	long long int n, m, ans,k;
	//t++;
	while (t--) {
		cin >> n;
			n /= 2;//dist
			cout << 1ll * 8 * n*(n + 1)*(2 * n + 1) / 6 << endl;
	}

}


#include<iostream>
using namespace std;
int t;
long long int n;

int main()
{
    cin>>t;
    for(int i=0;i<t;i++)
    {
        cin>>n;
        cout<<(n*(n+1)*(n-1))/3<<"\n";
    }
    return 0;
}


#include<iostream>
#include<algorithm>
using namespace std;
int main() {
	int t;
	cin >> t;
	for (int i = 0; i < t; i++) {
		int n;
			cin >> n;
			long long sum = 0;
			if (n == 1) {
				sum = 0;
			}
			else {
				long long counter = 1;
				for (int j = 3; j <= n; j += 2) {
					sum += (j * 4 - 4)*counter;
					counter++;
				}
			}
			cout << sum << endl;
	}

	return 0;
}


#include<iostream>
#include<algorithm>
using namespace std;
int main() {
	int t;
	cin >> t;
	for (int i = 0; i < t; i++) {
		int n;
			cin >> n;
			long long sum = 0;
			for (int j = 3; j <= n; j+=2) {
				sum += (j * 4 - 4)*j;
			}
			sum += 1;
	}

	return 0;
}


#include <iostream>
#include<cmath>
#include<algorithm>
#include<string>
using namespace std;
int main(){
    long long int t,n,count,i,j;
    cin>>t;
    while(t--){
        count = 0;
        i=1;
        j=0;
        cin>>n;
        while(i<=n){
            count+= (2*i+2*(i-2))*j;
            i+=2;
            j+=1;
        }
        cout<<count<<endl;
    }
}


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

const int MAXN = 101;
int grid[MAXN][MAXN], from[MAXN][MAXN];

struct P {
	int x, y;
};

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	memset(from, -1, sizeof from);
	int n, m;
	cin >> n >> m;
	int tx = -1, ty = -1;
	for(int i = 0; i < n; i++) {
		string s;
		cin >> s;
		for(int j = 0; j < m; j++) {
			if(s[j] == '.' || s[j] == 'F') {
				grid[i][j] = 1;
			}

			if(s[j] == 'F') {
				tx = i, ty = j;
			}
		}
	}

	auto valid = [&](int x, int y) {
		return 0 <= x && x < n && 0 <= y && y < m && grid[x][y] != 0;
	};

	int dx[] = {-1, 0, 0, 1};
	int dy[] = {0, -1, 1, 0};
	string moves = "ULRD";

	vector<P> q;
	q.push_back({0, 0});
	from[0][0] = 69;
	vector<int> path;
	for(int i = 0; i < (int) q.size(); i++) {
		P u = q[i];
		for(int k = 0; k < 4; k++) {
			int x = u.x + dx[k], y = u.y + dy[k];
			if(valid(x, y) && from[x][y] == -1) {
				from[x][y] = k;
				q.push_back({x, y});
			}
		}
	}

	while(tx != 0 || ty != 0) {
		int f = from[tx][ty];
		path.push_back(f);
		tx -= dx[f];
		ty -= dy[f];
	}

	reverse(path.begin(), path.end());
	bool know_x = false, know_y = false;
	int x = 0, y = 0;
	for(int k : path) {
		if(!know_x) {
			if((valid(x-1, y) && valid(x+1, y)) || (x == 0 && valid(x+1, y))) {
				cout << "U" << endl;
				int new_x, new_y;
				cin >> new_x >> new_y;
				new_x--, new_y--;
				if(new_x == x+1) {
					swap(moves[0], moves[3]);
				}
				know_x = true;
				if(new_x != x) {
					cout << "D" << endl;
					cin >> new_x >> new_y;
				}
			} else if(x == n-1 && valid(x-1, y)) {
				cout << "D" << endl;
				int new_x, new_y;
				cin >> new_x >> new_y;
				new_x--, new_y--;
				if(new_x == x-1) {
					swap(moves[0], moves[3]);
				}
				know_x = true;
				if(new_x != x) {
					cout << "U" << endl;
					cin >> new_x >> new_y;
				}
			}
		}

		if(!know_y) {
			if((valid(x, y-1) && valid(x, y+1)) || (y == 0 && valid(x, y+1))) {
				cout << "L" << endl;
				int new_x, new_y;
				cin >> new_x >> new_y;
				new_x--, new_y--;
				if(new_y == y+1) {
					swap(moves[1], moves[2]);
				}
				know_y = true;
				if(new_y != y) {
					cout << "R" << endl;
					cin >> new_x >> new_y;
				}
			} else if(y == m-1 && valid(x, y-1)) {
				cout << "R" << endl;
				int new_x, new_y;
				cin >> new_x >> new_y;
				new_x--, new_y--;
				if(new_y == y-1) {
					swap(moves[1], moves[2]);
				}
				know_y = true;
				if(new_y != y) {
					cout << "L" << endl;
					cin >> new_x >> new_y;
				}
			}
		}

		cout << moves[k] << endl;
		cin >> x >> y;
		x--, y--;
	}

}


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

const int MAXN = 101;
int grid[MAXN][MAXN], from[MAXN][MAXN];

struct P {
	int x, y;
};

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	memset(from, -1, sizeof from);
	int n, m;
	cin >> n >> m;
	int tx = -1, ty = -1;
	for(int i = 0; i < n; i++) {
		string s;
		cin >> s;
		for(int j = 0; j < m; j++) {
			if(s[j] == '.' || s[j] == 'F') {
				grid[i][j] = 1;
			}

			if(s[j] == 'F') {
				tx = i, ty = j;
			}
		}
	}

	auto valid = [&](int x, int y) {
		return 0 <= x && x < n && 0 <= y && y < m && grid[x][y] != 0;
	};

	int dx[] = {-1, 0, 0, 1};
	int dy[] = {0, -1, 1, 0};
	string moves = "ULRD";

	vector<P> q;
	q.push_back({0, 0});
	from[0][0] = 69;
	vector<int> path;
	for(int i = 0; i < (int) q.size(); i++) {
		P u = q[i];
		for(int k = 0; k < 4; k++) {
			int x = u.x + dx[k], y = u.y + dy[k];
			if(valid(x, y)&& from[x][y] == -1) {
				from[x][y] = k;
				q.push_back({x, y});
			}
		}
	}

	while(tx != 0 && ty != 0) {
		path.push_back(from[tx][ty]);
		tx -= dx[from[tx][ty]];
		ty -= dy[from[tx][ty]];
	}

	reverse(path.begin(), path.end());
	bool know_x = false, know_y = false;
	int x = 0, y = 0;
	for(int k : path) {
		if(!know_x) {
			if((valid(x-1, y) && valid(x+1, y)) || (x == 0 && valid(x+1, y))) {
				cout << "U" << endl;
				int new_x, new_y;
				cin >> new_x >> new_y;
				if(new_x == x+1) {
					swap(moves[0], moves[3]);
				}
				know_x = true;
				if(new_x != x) {
					cout << "D" << endl;
					cin >> new_x >> new_y;
				}
			} else if(x == n-1 && valid(x-1, y)) {
				cout << "D" << endl;
				int new_x, new_y;
				cin >> new_x >> new_y;
				if(new_x == x-1) {
					swap(moves[0], moves[3]);
				}
				know_x = true;
				if(new_x != x) {
					cout << "U" << endl;
					cin >> new_x >> new_y;
				}
			}
		}

		if(!know_y) {
			if((valid(x, y-1) && valid(x, y+1)) || (y == 0 && valid(x, y+1))) {
				cout << "L" << endl;
				int new_x, new_y;
				cin >> new_x >> new_y;
				if(new_y == y+1) {
					swap(moves[0], moves[3]);
				}
				know_y = true;
				if(new_y != y) {
					cout << "R" << endl;
					cin >> new_x >> new_y;
				}
			} else if(y == m-1 && valid(x, y-1)) {
				cout << "R" << endl;
				int new_x, new_y;
				cin >> new_x >> new_y;
				if(new_y == y-1) {
					swap(moves[1], moves[2]);
				}
				know_y = true;
				if(new_y != y) {
					cout << "L" << endl;
					cin >> new_x >> new_y;
				}
			}
		}

		cout << moves[k] << endl;
		cin >> x >> y;
	}
}


#include <bits/stdc++.h>

using namespace std;
using lint = long long;
using ulint = unsigned long long;

const int N = 101;

char grid[N][N];

int main(void) {
    //freopen("in.txt", "r", stdin);
    //freopen("out.txt", "w", stdout);
    ios_base::sync_with_stdio(false);
    //cin.tie(nullptr);

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

    int fx, fy;
    for (int i = 1; i <= n; i++) {
        string s;
        cin >> s;
        for (int j = 1; j <= m; j++) {
            grid[i][j] = s[j - 1];
            if (grid[i][j] == 'F') {
                fx = i;
                fy = j;
            }
        }
    }

    int x = 1, y = 1, aux_x, aux_y;
    bool knowUD = false, knowLR = false;
    bool invUD, invLR;

    while (grid[x][y] != 'F') {
        if (!knowUD && grid[x + 1][y] != '*') {
            cout << 'U' << endl;
            cin >> aux_x >> aux_y;
            knowUD = true;
            invUD = x + 1 == aux_x;
        } else if (!knowLR && grid[x][y + 1] != '*') {
            cout << 'L' << endl;
            cin >> aux_x >> aux_y;
            knowLR = true;
            invLR = y + 1 == aux_y;
        } else if (knowUD && knowLR) {
            map<tuple<int, int>, tuple<int, int>> parent;
            queue<tuple<int, int>> q;
            q.push({x, y});
            parent[{x, y}] = {0, 0};
            while (q.size()) {
                auto [i, j] = q.front();
                q.pop();

                const static pair<int, int> moves[] = {{1, 0}, {-1, 0}, {0, 1}, {0, -1}};
                for (auto mv : moves) {
                    int ix = i + mv.first, jy = j + mv.second;
                    if (ix > 0 && jy > 0 && ix <= n && jy <= m && grid[ix][jy] != '*' && !parent.count({ix, jy})) {
                        parent[{ix, jy}] = {i, j};
                        q.push({ix, jy});
                    }
                }
            }

            vector<char> moves;
            while (parent[{fx, fy}] != parent[{x, y}]) {
                auto [prev_x, prev_y] = parent[{fx, fy}];
                if (prev_x + 1 == fx) {
                    moves.push_back('D');
                } else if (prev_x - 1 == fx) {
                    moves.push_back('U');
                } else if (prev_y + 1 == fy) {
                    moves.push_back('R');
                } else if (prev_y - 1 == fy) {
                    moves.push_back('L');
                }
                tie(fx, fy) = parent[{fx, fy}];
            }
            reverse(moves.begin(), moves.end());
            for (auto mv : moves) {
                if (invUD && (mv == 'U' || mv == 'D')) mv = mv == 'U' ? 'D' : 'U';
                if (invLR && (mv == 'L' || mv == 'R')) mv = mv == 'L' ? 'R' : 'L';
                cout << mv << endl;
                cin >> aux_x >> aux_y;
            }
        } else if (knowUD) {
            char dir = 'D';
            for (int k = 1; k <= n; k++) {
                if (grid[k][y + 1] != '*') {
                    dir = k < x ? 'U' : 'D';
                    break;
                }
            }
            if (invUD) dir = dir == 'U' ? 'D' : 'U';
            cout << dir << endl;
            cin >> aux_x >> aux_y;
        } else if (knowLR) {
            char dir = 'R';
            for (int k = 1; k <= n; k++) {
                if (grid[x + 1][k] != '*') {
                    dir = k < y ? 'L' : 'R';
                    break;
                }
            }
            if (invLR) dir = dir == 'L' ? 'R' : 'L';
            cout << dir << endl;
            cin >> aux_x >> aux_y;
        } else {
            throw "fail";
        }

        tie(x, y) = {aux_x, aux_y};
    }
}


#include <bits/stdc++.h>

using namespace std;
using lint = long long;
using ulint = unsigned long long;

const int N = 101;

char grid[N][N];

int main(void) {
    //freopen("in.txt", "r", stdin);
    //freopen("out.txt", "w", stdout);
    ios_base::sync_with_stdio(false);
    //cin.tie(nullptr);

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

    int fx, fy;
    for (int i = 1; i <= n; i++) {
        string s;
        cin >> s;
        for (int j = 1; j <= m; j++) {
            grid[i][j] = s[j - 1];
            if (grid[i][j] == 'F') {
                fx = i;
                fy = j;
            }
        }
    }

    int x = 1, y = 1, aux_x, aux_y;
    bool knowUD = false, knowLR = false;
    bool invUD, invLR;

    while (grid[x][y] != 'F') {
        if (!knowUD && grid[x + 1][y] != '*') {
            cout << 'U' << endl;
            cin >> aux_x >> aux_y;
            knowUD = true;
            invUD = x + 1 == aux_x;
        } else if (!knowLR && grid[x][y + 1] != '*') {
            cout << 'L' << endl;
            cin >> aux_x >> aux_y;
            knowLR = true;
            invLR = y + 1 == aux_y;
        } else if (knowUD && knowLR) {
            map<tuple<int, int>, tuple<int, int>> parent;
            queue<tuple<int, int>> q;
            q.push({x, y});
            parent[{x, y}] = {0, 0};
            while (q.size()) {
                auto [i, j] = q.front();
                q.pop();

                const static pair<int, int> moves[] = {{1, 0}, {-1, 0}, {0, 1}, {0, -1}};
                for (auto mv : moves) {
                    int ix = i + mv.first, jy = j + mv.second;
                    if (ix > 0 && jy > 0 && ix <= n && jy <= m && grid[ix][jy] != '*' && !parent.count({ix, jy})) {
                        parent[{ix, jy}] = {i, j};
                        q.push({ix, jy});
                    }
                }
            }

            vector<char> moves;
            while (parent[{fx, fy}] != parent[{x, y}]) {
                auto [prev_x, prev_y] = parent[{fx, fy}];
                if (prev_x + 1 == fx) {
                    moves.push_back('D');
                } else if (prev_x - 1 == fx) {
                    moves.push_back('U');
                } else if (prev_y + 1 == fy) {
                    moves.push_back('R');
                } else if (prev_y - 1 == fy) {
                    moves.push_back('L');
                }
                tie(fx, fy) = parent[{fx, fy}];
            }
            reverse(moves.begin(), moves.end());
            for (auto mv : moves) {
                if (invUD && (mv == 'U' || mv == 'D')) mv = mv == 'U' ? 'D' : 'U';
                if (invLR && (mv == 'L' || mv == 'R')) mv = mv == 'L' ? 'R' : 'L';
                cout << mv << endl;
                cin >> aux_x >> aux_y;
            }
        } else if (knowUD) {
            char dir = 'D';
            for (int k = 1; k <= n; k++) {
                if (grid[k][y + 1] != '*') {
                    dir = k < x ? 'U' : 'D';
                    break;
                }
            }
            if (invUD) dir = dir == 'U' ? 'D' : 'U';
            cout << dir << endl;
            cin >> aux_x >> aux_y;
        } else if (knowLR) {
            char dir = 'R';
            for (int k = 1; k <= n; k++) {
                if (grid[x + 1][k] != '*') {
                    dir = k < y ? 'L' : 'R';
                    break;
                }
            }
            if (invLR) dir = dir == 'L' ? 'R' : 'L';
            cout << dir << endl;
            cin >> aux_x >> aux_y;
        } else {
            throw exception("fail");
        }

        tie(x, y) = {aux_x, aux_y};
    }
}


#include <bits/stdc++.h>

using namespace std;
using lint = long long;
using ulint = unsigned long long;

const int N = 101;

char grid[N][N];

int main(void) {
    //freopen("in.txt", "r", stdin);
    //freopen("out.txt", "w", stdout);
    ios_base::sync_with_stdio(false);
    //cin.tie(nullptr);

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

    int fx, fy;
    for (int i = 1; i <= n; i++) {
        string s;
        cin >> s;
        for (int j = 1; j <= m; j++) {
            grid[i][j] = s[j - 1];
            if (grid[i][j] == 'F') {
                fx = i;
                fy = j;
            }
        }
    }

    int x = 1, y = 1, aux_x, aux_y;
    bool knowUD = false, knowLR = false;
    bool invUD, invLR;

    while (grid[x][y] != 'F') {
        if (!knowUD && grid[x + 1][y] != '*') {
            cout << 'U' << endl;
            cin >> aux_x >> aux_y;
            knowUD = true;
            invUD = x + 1 == aux_x;
        } else if (!knowLR && grid[x][y + 1] != '*') {
            cout << 'L' << endl;
            cin >> aux_x >> aux_y;
            knowLR = true;
            invLR = y + 1 == aux_y;
        } else if (knowUD && knowLR) {
            map<tuple<int, int>, tuple<int, int>> parent;
            queue<tuple<int, int>> q;
            q.push({x, y});
            parent[{x, y}] = {0, 0};
            while (q.size()) {
                auto [i, j] = q.front();
                q.pop();

                const static pair<int, int> moves[] = {{1, 0}, {-1, 0}, {0, 1}, {0, -1}};
                for (auto mv : moves) {
                    int ix = i + mv.first, jy = j + mv.second;
                    if (ix > 0 && jy > 0 && ix <= n && jy <= m && grid[ix][jy] != '*' && !parent.count({ix, jy})) {
                        parent[{ix, jy}] = {i, j};
                        q.push({ix, jy});
                    }
                }
            }

            vector<char> moves;
            while (parent[{fx, fy}] != parent[{x, y}]) {
                auto [prev_x, prev_y] = parent[{fx, fy}];
                if (prev_x + 1 == fx) {
                    moves.push_back('D');
                } else if (prev_x - 1 == fx) {
                    moves.push_back('U');
                } else if (prev_y + 1 == fy) {
                    moves.push_back('R');
                } else if (prev_y - 1 == fy) {
                    moves.push_back('L');
                }
                tie(fx, fy) = parent[{fx, fy}];
            }
            reverse(moves.begin(), moves.end());
            for (auto mv : moves) {
                if (invUD && (mv == 'U' || mv == 'D')) mv = mv == 'U' ? 'D' : 'U';
                if (invLR && (mv == 'L' || mv == 'R')) mv = mv == 'L' ? 'R' : 'L';
                cout << mv << endl;
                cin >> aux_x >> aux_y;
            }
        } else if (knowUD) {
            char dir;
            for (int k = 1; k <= n; k++) {
                if (grid[k][y + 1] != '*') {
                    dir = k < x ? 'U' : 'D';
                    break;
                }
            }
            if (invUD) dir = dir == 'U' ? 'D' : 'U';
            cout << dir << endl;
            cin >> aux_x >> aux_y;
        } else if (knowLR) {
            char dir;
            for (int k = 1; k <= n; k++) {
                if (grid[x + 1][k] != '*') {
                    dir = k < y ? 'L' : 'R';
                    break;
                }
            }
            if (invLR) dir = dir == 'L' ? 'R' : 'L';
            cout << dir << endl;
            cin >> aux_x >> aux_y;
        } else {
            throw "fail";
        }

        tie(x, y) = {aux_x, aux_y};
    }
}


#include <bits/stdc++.h>

using namespace std;
using lint = long long;
using ulint = unsigned long long;

const int N = 101;

char grid[N][N];

int main(void) {
    //freopen("in.txt", "r", stdin);
    //freopen("out.txt", "w", stdout);
    ios_base::sync_with_stdio(false);
    //cin.tie(nullptr);

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

    int fx, fy;
    for (int i = 1; i <= n; i++) {
        string s;
        cin >> s;
        for (int j = 1; j <= m; j++) {
            grid[i][j] = s[j - 1];
            if (grid[i][j] == 'F') {
                fx = i;
                fy = j;
            }
        }
    }

    int x = 1, y = 1, aux_x, aux_y;
    bool knowUD = false, knowLR = false;
    bool invUD, invLR;

    while (grid[x][y] != 'F') {
        if (!knowUD && grid[x + 1][y] != '*') {
            cout << 'U' << endl;
            cin >> aux_x >> aux_y;
            knowUD = true;
            invUD = x + 1 == aux_x;
        } else if (!knowLR && grid[x][y + 1] != '*') {
            cout << 'L' << endl;
            cin >> aux_x >> aux_y;
            knowLR = true;
            invLR = y + 1 == aux_y;
        } else if (knowUD && knowLR) {
            map<tuple<int, int>, tuple<int, int>> parent;
            queue<tuple<int, int>> q;
            q.push({x, y});
            parent[{x, y}] = {0, 0};
            while (q.size()) {
                auto [i, j] = q.front();
                q.pop();

                const static pair<int, int> moves[] = {{1, 0}, {-1, 0}, {0, 1}, {0, -1}};
                for (auto mv : moves) {
                    int ix = i + mv.first, jy = j + mv.second;
                    if (ix > 0 && jy > 0 && ix <= n && jy <= m && grid[ix][jy] != '*' && !parent.count({ix, jy})) {
                        parent[{ix, jy}] = {i, j};
                        q.push({ix, jy});
                    }
                }
            }

            vector<char> moves;
            while (parent[{fx, fy}] != parent[{x, y}]) {
                auto [prev_x, prev_y] = parent[{fx, fy}];
                if (prev_x + 1 == fx) {
                    moves.push_back('D');
                } else if (prev_x - 1 == fx) {
                    moves.push_back('U');
                } else if (prev_y + 1 == fy) {
                    moves.push_back('R');
                } else if (prev_y - 1 == fy) {
                    moves.push_back('L');
                }
                tie(fx, fy) = parent[{fx, fy}];
            }
            reverse(moves.begin(), moves.end());
            for (auto mv : moves) {
                if (invUD && (mv == 'U' || mv == 'D')) mv = mv == 'U' ? 'D' : 'U';
                if (invLR && (mv == 'L' || mv == 'R')) mv = mv == 'L' ? 'R' : 'L';
                cout << mv << endl;
                cin >> aux_x >> aux_y;
            }
        } else if (knowUD) {
            char dir;
            for (int k = 1; k <= n; k++) {
                if (grid[k][y + 1] != '*') {
                    dir = k < x ? 'U' : 'D';
                    break;
                }
            }
            if (invUD) dir = dir == 'U' ? 'D' : 'U';
            cout << dir << endl;
            cin >> aux_x >> aux_y;
        } else if (knowLR) {
            char dir;
            for (int k = 1; k <= n; k++) {
                if (grid[x + 1][k] != '*') {
                    dir = k < y ? 'L' : 'R';
                    break;
                }
            }
            if (invLR) dir = dir == 'L' ? 'R' : 'L';
            cout << dir << endl;
            cin >> aux_x >> aux_y;
        } else {
            throw exception("fail");
        }

        tie(x, y) = {aux_x, aux_y};
    }
}


#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
using namespace std;
int n,m,ok1=0,ok2=0,res1=0,res2=0,px=0,py=0,a,b;
int gx,gy,dis[107][107];
pair <int,int> nxt[107][107];
int dx[]={+1,-1,0,0};
int dy[]={0,0,+1,-1};
char s[107][107];
int ck(int x,int y,int k){
    if(k==1){
        if(y!=0){
            if(s[x][y-1]=='*') return 0;
        }
        if(y!=m-1){
            if(s[x][y+1]=='*') return 0;
        }
    }
    else{
        if(x!=0){
            if(s[x-1][y]=='*') return 0;
        }
        if(x!=n-1){
            if(s[x+1][y]=='*') return 0;
        }
    }
    return 1;
}
void finans(){
    while(s[px][py]!='F'){
        int x=nxt[px][py].fi,y=nxt[px][py].se;
        if(x!=px){
            if(x==px+1){
                if(res2==0){
                    cout<<"D"<<endl;
                }
                else{
                    cout<<"U"<<endl;
                }
                cin>>a>>b;
            }
            else{
                if(res2==0){
                    cout<<"U"<<endl;
                }
                else{
                    cout<<"D"<<endl;
                }
                cin>>a>>b;
            }
        }
        else{
            if(y==py+1){
                if(res1==0){
                    cout<<"R"<<endl;
                }
                else{
                    cout<<"L"<<endl;
                }
                cin>>a>>b;
            }
            else{
                if(res1==0){
                    cout<<"L"<<endl;
                }
                else{
                    cout<<"R"<<endl;
                }
                cin>>a>>b;
            }
        }
        px=x;
        py=y;
    }
}
int main(){
    ios_base::sync_with_stdio(0);
    cin>>n>>m;
    for(int i=0;i<n;i++){
        cin>>s[i];
    }
    if(s[0][0]=='F') return 0;
    while(ok1==0 || ok2==0){
        if(s[px][py]=='F'){
            return 0;
        }
        if(ok1==0 && ck(px,py,1)==1){
            cout<<"R"<<endl;
            cin>>a>>b;
            a--;
            b--;
            if(s[a][b]=='F') return 0;
            if(b==py+1){
                res1=0;
                cout<<"L"<<endl;
                cin>>a>>b;
                a--;
                b--;
                px=a;
                py=b;
            }
            else{
                res1=1;
            }
            ok1=1;
        }
        if(ok2==0 && ck(px,py,2)==1){
            cout<<"D"<<endl;
            cin>>a>>b;
            a--;
            b--;
            if(s[a][b]=='F') return 0;
            if(a==px+1){
                res2=0;
                cout<<"U"<<endl;
                cin>>a>>b;
                a--;
                b--;
                px=a;
                py=b;
            }
            else{
                res2=1;
            }
            ok2=1;
        }
        if(ck(px,py,1)==0 && ok1==0){
            px++;
            if(res2==0){
                cout<<"D"<<endl;
            }
            else{
                cout<<"U"<<endl;
            }
            cin>>a>>b;
            a--;
            b--;
            if(s[a][b]=='F') return 0;
        }
        if(ck(px,py,2)==0 && ok2==0){
            py++;
            if(res1==0){
                cout<<"R"<<endl;
            }
            else{
                cout<<"L"<<endl;
            }
            cin>>a>>b;
            a--;
            b--;
            if(s[a][b]=='F') return 0;
        }
    }
    for(int i=0;i<n;i++){
        for(int j=0;j<m;j++){
            if(s[i][j]=='F'){
                gx=i;
                gy=j;
            }
            dis[i][j]=1e8;
        }
    }
    priority_queue < pair< int ,pair<int,int> > , vector < pair < int,pair<int,int> > >, greater < pair< int,pair<int,int> > > > pr;
    pr.push(mp(0,mp(gx,gy)));
    dis[gx][gy]=0;
    while(!pr.empty()){
        int val=pr.top().fi;
        int x=pr.top().se.fi,y=pr.top().se.se;
        pr.pop();
        if(val==dis[x][y]){
            for(int i=0;i<4;i++){
                int kx=x+dx[i],ky=y+dy[i];
                if(kx<0 || ky<0 || kx>=n || ky>=m || s[kx][ky]=='*' || dis[kx][ky]<=val+1) continue;
                dis[kx][ky]=val+1;
                pr.push(mp(val+1,mp(kx,ky)));
                nxt[kx][ky]=mp(x,y);
            }
        }
    }
    finans();
}


#include<bits/stdc++.h>
using namespace std;
char tab[105][105];
bool odw[105][105];
vector<pair<int,int>> ruchy;
vector<pair<int,int>> v;
bool pion=false;
bool poz=false;
bool xd=false;
bool xd1=false;
bool xd2=false;
void pre()
{
    for(int x=0;x<=103;x++)
        for(int y=0;y<=103;y++)
            tab[x][y]='*';
}
void dfs(int a,int b)
{
    odw[a][b]=true;
    int x=a,y=b;
    ruchy.push_back(make_pair(a,b));
    if(tab[a][b]=='F')
        xd=true;
    if(xd==true)
        return;
    if(tab[x-1][y]!='*'&&odw[x-1][y]==false)
        dfs(x-1,y);
    if(xd==true)
        return;
    if(tab[x+1][y]!='*'&&odw[x+1][y]==false)
        dfs(x+1,y);
    if(xd==true)
        return;
    if(tab[x][y-1]!='*'&&odw[x][y-1]==false)
        dfs(x,y-1);
    if(xd==true)
        return;
    if(tab[x][y+1]!='*'&&odw[x][y+1]==false)
        dfs(x,y+1);
    if(xd==true)
        return;
    ruchy.pop_back();
}
char conv(pair<int,int> p)
{
    if(pion==true)
        p.first*=(-1);
    if(poz==true)
        p.second*=(-1);
    if(p.first==0)
    {
        if(p.second==-1)
            return 'L';
        else
            return 'R';
    }
    else
    {
        if(p.first==-1)
            return 'U';
        else
            return 'D';
    }

}
int main()
{
    ios_base::sync_with_stdio(0);
    //cin.tie(0);
    int a,b;
    pre();
    cin>>a>>b;
    for(int x=1;x<=a;x++)
        for(int y=1;y<=b;y++)
            cin>>tab[x][y];
    dfs(1,1);
    for(int x=0;x<ruchy.size()-1;x++)
        v.push_back(make_pair(ruchy[x+1].first-ruchy[x].first,ruchy[x+1].second-ruchy[x].second));
    pair<int,int> p1=make_pair(1,1),p2;
    for(auto x:v)
    {
        cout<<conv(x)<<'\n';
        fflush(stdout);
        cin>>p2.first>>p2.second;
        if((conv(x)=='L'||conv(x)=='R')&&xd1==false)
        {
            xd1=true;
            if(p1==p2)
            {
                poz=true;
                cout<<conv(x)<<'\n';
                fflush(stdout);
                cin>>p2.first>>p2.second;
            }
        }
        if((conv(x)=='U'||conv(x)=='D')&&xd2==false)
        {
            xd2=true;
            if(p1==p2)
            {
                pion=true;
                cout<<conv(x)<<'\n';
                fflush(stdout);
                cin>>p2.first>>p2.second;
            }
        }
        p1=p2;
    }
    return 0;
}


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

/*
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp>
#include <functional> // for less
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag,
		   tree_order_statistics_node_update> oset;
*/

#define IO            ios::sync_with_stdio(false);cin.tie(0);

#define int           long long
#define pi            pair<int,int>
#define pii           pair<int,pi>
#define vi            vector<int>
#define vs            vector<string>
#define vb            vector<bool>
#define vii           vector<vector<int>>
#define vpi           vector<pi>
#define pb            push_back
#define mp            make_pair
#define eb            emplace_back
#define ff            first
#define ss            second
#define fo(i,x,n)     for(int i = x ; i < n  ; i++)
#define rfo(i,x,j)    for(int i = x ; i >= j ; i--)
#define all(x)        x.begin(),x.end()
//#define inf           1e12
#define inf           0x3f3f3f3f3f3f3f3fLL
#define endl          '\n'

mt19937 rnd(time(0));

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

int pw(int b, int p){
	b %= MOD;

	int res = 1;

	while(p > 0){
		if(p & 1)
			res = res * b % MOD;
		b = b * b % MOD;
		p >>= 1;
	}
	return res;
}

int X[] = {-1,0,0,1};
int Y[] = {0,-1,1,0};

int n,m,FX,FY , curx,cury;
bool swapLR , swapUD;
char mat[107][107];
int dist[107][107];

void L(){
	cout << (swapLR ? "R" : "L") << endl;
	cout.flush();

	int x , y;
	cin >> x >> y;
	x-- , y--;

	if(x == curx , y == cury){
		swapLR = !swapLR;
		L();
	}
	else{
		curx = x;
		cury = y;
	}
}

void R(){
	cout << (swapLR ? "L" : "R") << endl;
	cout.flush();

	int x , y;
	cin >> x >> y;
	x-- , y--;

	if(x == curx , y == cury){
		swapLR = !swapLR;
		R();
	}
	else{
		curx = x;
		cury = y;
	}
}

void U(){
	cout << (swapUD ? "D" : "U") << endl;
	cout.flush();

	int x , y;
	cin >> x >> y;
	x-- , y--;

	if(x == curx , y == cury){
		swapUD = !swapUD;
		U();
	}
	else{
		curx = x;
		cury = y;
	}
}

void D(){
	cout << (swapUD ? "U" : "D") << endl;
	cout.flush();

	int x , y;
	cin >> x >> y;
	x-- , y--;

	if(x == curx , y == cury){
		swapUD = !swapUD;
		D();
	}
	else{
		curx = x;
		cury = y;
	}
}

bool check(int a,int b){
	return (a >= 0 && a < n && b >= 0 && b < m);
}

void bfs(){
	queue<pi> q;
	q.push({FX , FY});
	dist[FX][FY] = 1;

	while(!q.empty()){
		pi p = q.front();
		int d = dist[p.ff][p.ss] + 1;

		q.pop();

		fo(i,0,4){
			int x = p.ff + X[i];
			int y = p.ss + Y[i];

			if(check(x , y) && dist[x][y] == 0 && mat[x][y] == '.'){
				q.push({x , y});
				dist[x][y] = d;
			}
		}
	}
}

int32_t main(){

	IO

	cin >> n >> m;

	fo(i,0,n){
		fo(j,0,m){
			cin >> mat[i][j];
			if(mat[i][j] == 'F')
				FX = i , FY = j;
		}
	}

	bfs();

	while(curx != FX || cury != FY){
		int d = dist[curx][cury];
		fo(i,0,4){
			int x = curx + X[i];
			int y = cury + Y[i];

			if(check(curx , cury) && dist[x][y] == d - 1){
				if(i == 0) U();
				else if(i == 1) L();
				else if(i == 2) R();
				else D();
			}
		}
	}

	return 0;
}


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

/*
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp>
#include <functional> // for less
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag,
		   tree_order_statistics_node_update> oset;
*/

#define IO            ios::sync_with_stdio(false);cin.tie(0);

#define int           long long
#define pi            pair<int,int>
#define pii           pair<int,pi>
#define vi            vector<int>
#define vs            vector<string>
#define vb            vector<bool>
#define vii           vector<vector<int>>
#define vpi           vector<pi>
#define pb            push_back
#define mp            make_pair
#define eb            emplace_back
#define ff            first
#define ss            second
#define fo(i,x,n)     for(int i = x ; i < n  ; i++)
#define rfo(i,x,j)    for(int i = x ; i >= j ; i--)
#define all(x)        x.begin(),x.end()
//#define inf           1e12
#define inf           0x3f3f3f3f3f3f3f3fLL
#define endl          '\n'

mt19937 rnd(time(0));

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

int pw(int b, int p){
	b %= MOD;

	int res = 1;

	while(p > 0){
		if(p & 1)
			res = res * b % MOD;
		b = b * b % MOD;
		p >>= 1;
	}
	return res;
}

int X[] = {-1,0,0,1};
int Y[] = {0,-1,1,0};

int n,m,FX,FY , curx,cury;
bool swapLR , swapUD;
char mat[107][107];
int dist[107][107];

void L(){
	cout << (swapLR ? "R" : "L") << endl;
	cout.flush();

	int x , y;
	cin >> x >> y;
	x-- , y--;

	if(x == curx , y == cury){
		swapLR = !swapLR;
		L();
	}
	else{
		curx = x;
		cury = y;
	}
}

void R(){
	cout << (swapLR ? "L" : "R") << endl;
	cout.flush();

	int x , y;
	cin >> x >> y;
	x-- , y--;

	if(x == curx , y == cury){
		swapLR = !swapLR;
		R();
	}
	else{
		curx = x;
		cury = y;
	}
}

void U(){
	cout << (swapUD ? "D" : "U") << endl;
	cout.flush();

	int x , y;
	cin >> x >> y;
	x-- , y--;

	if(x == curx , y == cury){
		swapUD = !swapUD;
		U();
	}
	else{
		curx = x;
		cury = y;
	}
}

void D(){
	cout << (swapUD ? "U" : "D") << endl;
	cout.flush();

	int x , y;
	cin >> x >> y;
	x-- , y--;

	if(x == curx , y == cury){
		swapUD = !swapUD;
		D();
	}
	else{
		curx = x;
		cury = y;
	}
}

bool check(int a,int b){
	return (a >= 0 && a < n && b >= 0 && b < m);
}

void bfs(){
	queue<pi> q;
	q.push({FX , FY});
	dist[FX][FY] = 1;

	while(!q.empty()){
		pi p = q.front();
		int d = dist[p.ff][p.ss] + 1;

		q.pop();

		fo(i,0,4){
			int x = p.ff + X[i];
			int y = p.ss + Y[i];

			if(check(x , y) && dist[x][y] == 0 && mat[x][y] == '.'){
				q.push({x , y});
				dist[x][y] = d;
			}
		}
	}
}

int32_t main(){

	IO

	cin >> n >> m;

	fo(i,0,n){
		fo(j,0,m){
			cin >> mat[i][j];
			if(mat[i][j] == 'F')
				FX = i , FY = j;
		}
	}

	bfs();

	//fo(i,0,n){
	//	fo(j,0,m){
	//		cout << dist[i][j] << ' ';
	//	}
	//	cout << endl;
	//}

	while(curx != FX || cury != FY){
		int d = dist[curx][cury];
		fo(i,0,4){
			int x = curx + X[i];
			int y = cury + Y[i];

			if(check(x , y) && dist[x][y] == d - 1){
				if(i == 0) U();
				else if(i == 1) L();
				else if(i == 2) R();
				else D();
				break;
			}
		}
	}

	return 0;
}


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

/*
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp>
#include <functional> // for less
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag,
		   tree_order_statistics_node_update> oset;
*/

#define IO            ios::sync_with_stdio(false);cin.tie(0);

#define int           long long
#define pi            pair<int,int>
#define pii           pair<int,pi>
#define vi            vector<int>
#define vs            vector<string>
#define vb            vector<bool>
#define vii           vector<vector<int>>
#define vpi           vector<pi>
#define pb            push_back
#define mp            make_pair
#define eb            emplace_back
#define ff            first
#define ss            second
#define fo(i,x,n)     for(int i = x ; i < n  ; i++)
#define rfo(i,x,j)    for(int i = x ; i >= j ; i--)
#define all(x)        x.begin(),x.end()
//#define inf           1e12
#define inf           0x3f3f3f3f3f3f3f3fLL
#define endl          '\n'

mt19937 rnd(time(0));

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

int pw(int b, int p){
	b %= MOD;

	int res = 1;

	while(p > 0){
		if(p & 1)
			res = res * b % MOD;
		b = b * b % MOD;
		p >>= 1;
	}
	return res;
}

int X[] = {-1,0,0,1};
int Y[] = {0,-1,1,0};

int n,m,FX,FY , curx,cury;
bool swapLR , swapUD;
char mat[107][107];
int dist[107][107];

void L(){
	cout << (swapLR ? "R" : "L") << endl;
	cout.flush();

	int x , y;
	cin >> x >> y;
	x-- , y--;

	if(x == curx , y == cury){
		swapLR = !swapLR;
		L();
	}
	else{
		curx = x;
		cury = y;
	}
}

void R(){
	cout << (swapLR ? "L" : "R") << endl;
	cout.flush();

	int x , y;
	cin >> x >> y;
	x-- , y--;

	if(x == curx , y == cury){
		swapLR = !swapLR;
		R();
	}
	else{
		curx = x;
		cury = y;
	}
}

void U(){
	cout << (swapUD ? "D" : "U") << endl;
	cout.flush();

	int x , y;
	cin >> x >> y;
	x-- , y--;

	if(x == curx , y == cury){
		swapUD = !swapUD;
		U();
	}
	else{
		curx = x;
		cury = y;
	}
}

void D(){
	cout << (swapUD ? "U" : "D") << endl;
	cout.flush();

	int x , y;
	cin >> x >> y;
	x-- , y--;

	if(x == curx , y == cury){
		swapUD = !swapUD;
		D();
	}
	else{
		curx = x;
		cury = y;
	}
}

bool check(int a,int b){
	return (a >= 0 && a < n && b >= 0 && b < m);
}

void bfs(){
	queue<pi> q;
	q.push({FX , FY});
	dist[FX][FY] = 1;

	while(!q.empty()){
		pi p = q.front();
		int d = dist[p.ff][p.ss] + 1;

		q.pop();

		fo(i,0,4){
			int x = p.ff + X[i];
			int y = p.ss + Y[i];

			if(check(x , y) && dist[x][y] == 0 && mat[x][y] == '.'){
				q.push({x , y});
				dist[x][y] = d;
			}
		}
	}
}

int32_t main(){

	IO

	cin >> n >> m;

	fo(i,0,n){
		fo(j,0,m){
			cin >> mat[i][j];
			if(mat[i][j] == 'F')
				FX = i , FY = j;
		}
	}

	bfs();

	while(curx != FX || cury != FY){
		int d = dist[curx][cury];
		fo(i,0,4){
			int x = curx + X[i];
			int y = cury + Y[i];

			if(check(x , y) && dist[x][y] == d - 1){
				if(i == 0) U();
				else if(i == 1) L();
				else if(i == 2) R();
				else D();
			}
		}
	}

	return 0;
}


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

/*
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp>
#include <functional> // for less
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag,
		   tree_order_statistics_node_update> oset;
*/

#define IO            ios::sync_with_stdio(false);cin.tie(0);

#define int           long long
#define pi            pair<int,int>
#define pii           pair<int,pi>
#define vi            vector<int>
#define vs            vector<string>
#define vb            vector<bool>
#define vii           vector<vector<int>>
#define vpi           vector<pi>
#define pb            push_back
#define mp            make_pair
#define eb            emplace_back
#define ff            first
#define ss            second
#define fo(i,x,n)     for(int i = x ; i < n  ; i++)
#define rfo(i,x,j)    for(int i = x ; i >= j ; i--)
#define all(x)        x.begin(),x.end()
//#define inf           1e12
#define inf           0x3f3f3f3f3f3f3f3fLL
#define endl          '\n'

mt19937 rnd(time(0));

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

int pw(int b, int p){
	b %= MOD;

	int res = 1;

	while(p > 0){
		if(p & 1)
			res = res * b % MOD;
		b = b * b % MOD;
		p >>= 1;
	}
	return res;
}

int X[] = {-1,0,0,1};
int Y[] = {0,-1,1,0};

int n,m,FX,FY , curx,cury;
bool swapLR , swapUD;
char mat[107][107];
int dist[107][107];

void L(){
	cout << (swapLR ? "R" : "L") << endl;
	int x , y;
	cin >> x >> y;
	x-- , y--;

	if(x == curx , y == cury){
		swapLR = !swapLR;
		L();
	}
	else{
		curx = x;
		cury = y;
	}
}

void R(){
	cout << (swapLR ? "L" : "R") << endl;
	int x , y;
	cin >> x >> y;
	x-- , y--;

	if(x == curx , y == cury){
		swapLR = !swapLR;
		R();
	}
	else{
		curx = x;
		cury = y;
	}
}

void U(){
	cout << (swapUD ? "D" : "U") << endl;
	int x , y;
	cin >> x >> y;
	x-- , y--;

	if(x == curx , y == cury){
		swapUD = !swapUD;
		U();
	}
	else{
		curx = x;
		cury = y;
	}
}

void D(){
	cout << (swapUD ? "U" : "D") << endl;
	int x , y;
	cin >> x >> y;
	x-- , y--;

	if(x == curx , y == cury){
		swapUD = !swapUD;
		D();
	}
	else{
		curx = x;
		cury = y;
	}
}

bool check(int a,int b){
	return (a >= 0 && a < n && b >= 0 && b < m);
}

void bfs(){
	queue<pi> q;
	q.push({FX , FY});
	dist[FX][FY] = 1;

	while(!q.empty()){
		pi p = q.front();
		int d = dist[p.ff][p.ss] + 1;

		q.pop();

		fo(i,0,4){
			int x = p.ff + X[i];
			int y = p.ss + Y[i];

			if(check(x , y) && dist[x][y] == 0 && mat[x][y] == '.'){
				q.push({x , y});
				dist[x][y] = d;
			}
		}
	}
}

int32_t main(){

	IO

	cin >> n >> m;

	fo(i,0,n){
		fo(j,0,m){
			cin >> mat[i][j];
			if(mat[i][j] == 'F')
				FX = i , FY = j;
		}
	}

	bfs();

	while(curx != FX || cury != FY){
		int d = dist[curx][cury];
		fo(i,0,4){
			int x = curx + X[i];
			int y = cury + Y[i];

			if(check(curx , cury) && dist[x][y] == d - 1){
				if(i == 0) U();
				else if(i == 1) L();
				else if(i == 2) R();
				else D();
			}
		}
	}

	return 0;
}


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

/*
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp>
#include <functional> // for less
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag,
		   tree_order_statistics_node_update> oset;
*/

#define IO            ios::sync_with_stdio(false);cin.tie(0);

#define int           long long
#define pi            pair<int,int>
#define pii           pair<int,pi>
#define vi            vector<int>
#define vs            vector<string>
#define vb            vector<bool>
#define vii           vector<vector<int>>
#define vpi           vector<pi>
#define pb            push_back
#define mp            make_pair
#define eb            emplace_back
#define ff            first
#define ss            second
#define fo(i,x,n)     for(int i = x ; i < n  ; i++)
#define rfo(i,x,j)    for(int i = x ; i >= j ; i--)
#define all(x)        x.begin(),x.end()
//#define inf           1e12
#define inf           0x3f3f3f3f3f3f3f3fLL
#define endl          '\n'

mt19937 rnd(time(0));

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

int pw(int b, int p){
	b %= MOD;

	int res = 1;

	while(p > 0){
		if(p & 1)
			res = res * b % MOD;
		b = b * b % MOD;
		p >>= 1;
	}
	return res;
}

int X[] = {-1,0,0,1};
int Y[] = {0,-1,1,0};

int n,m,FX,FY , curx,cury;
bool swapLR , swapUD;
char mat[107][107];
int dist[107][107];

void L(){
	cout << (swapLR ? "R" : "L") << endl;
	cout.flush();

	int x , y;
	cin >> x >> y;
	x-- , y--;

	if(x == curx && y == cury){
		swapLR = !swapLR;
		L();
	}
	else{
		curx = x;
		cury = y;
	}
}

void R(){
	cout << (swapLR ? "L" : "R") << endl;
	cout.flush();

	int x , y;
	cin >> x >> y;
	x-- , y--;

	if(x == curx && y == cury){
		swapLR = !swapLR;
		R();
	}
	else{
		curx = x;
		cury = y;
	}
}

void U(){
	cout << (swapUD ? "D" : "U") << endl;
	cout.flush();

	int x , y;
	cin >> x >> y;
	x-- , y--;

	if(x == curx && y == cury){
		swapUD = !swapUD;
		U();
	}
	else{
		curx = x;
		cury = y;
	}
}

void D(){
	cout << (swapUD ? "U" : "D") << endl;
	cout.flush();

	int x , y;
	cin >> x >> y;
	x-- , y--;

	if(x == curx && y == cury){
		swapUD = !swapUD;
		D();
	}
	else{
		curx = x;
		cury = y;
	}
}

bool check(int a,int b){
	return (a >= 0 && a < n && b >= 0 && b < m);
}

void bfs(){
	queue<pi> q;
	q.push({FX , FY});
	dist[FX][FY] = 1;

	while(!q.empty()){
		pi p = q.front();
		int d = dist[p.ff][p.ss] + 1;

		q.pop();

		fo(i,0,4){
			int x = p.ff + X[i];
			int y = p.ss + Y[i];

			if(check(x , y) && dist[x][y] == 0 && mat[x][y] == '.'){
				q.push({x , y});
				dist[x][y] = d;
			}
		}
	}
}

int32_t main(){

	IO

	cin >> n >> m;

	fo(i,0,n){
		fo(j,0,m){
			cin >> mat[i][j];
			if(mat[i][j] == 'F')
				FX = i , FY = j;
		}
	}

	bfs();

	//fo(i,0,n){
	//	fo(j,0,m){
	//		cout << dist[i][j] << ' ';
	//	}
	//	cout << endl;
	//}

	//cout << FX << ' ' << FY << endl;

	while(curx != FX || cury != FY){
		int d = dist[curx][cury];
		fo(i,0,4){
			int x = curx + X[i];
			int y = cury + Y[i];

			if(check(x , y) && dist[x][y] == d - 1){
				if(i == 0) U();
				else if(i == 1) L();
				else if(i == 2) R();
				else D();
				break;
			}
		}
		//cout << curx << ' ' << cury << endl;
	}

	return 0;
}


//#include "input.h"
//#include "output.h"
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")

#define NDEBUG
NDEBUG

#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cstring>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <memory>
#include <queue>
#include <random>

using namespace std;

template<class T>
using vec = std::vector<T>;

template<class T>
using vec2d = std::vector<std::vector<T>>;

template<class T>
vec2d<T> makeVec2d(const int n1, const int n2) {
  return vec2d<T>(n1, vec<T>(n2));
}

template<class T>
vec2d<T> makeVec2d(const int n1, const int n2, const T initValue) {
  return vec2d<T>(n1, vec<T>(n2, initValue));
}

#define FOR(i, n) for (int i = 0; i < (n); ++i)

#define FR(i, a, b) for (int i = (a); i <= (b); ++i)

#define all(c) c.begin(), c.end()

// TC_REMOVE_BEGIN
/// caide keep
bool __hack = std::ios::sync_with_stdio(false);
/// caide keep
auto __hack1 = cin.tie(nullptr);
// TC_REMOVE_END

// Section with adoption of array and vector algorithms.

//#include <ext/pb_ds/tree_policy.hpp>
//#include <ext/pb_ds/assoc_container.hpp>
//
//template <class T> using StdTree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;

//bool __hack = std::ios::sync_with_stdio(false);
//auto __hack1 = cin.tie(nullptr);

struct Input {

    Input(istream &in) : in(&in) {}

    template<class T>
    T next() const {
        T x;
        *in >> x;
        return x;
    }

    int ni() const {
        return next<int>();
    }

    string ns() const {
        return next<string>();
    }

    istream *in;
};

Input in(cin);

class Output {

private:
ostream *out;

template<typename T>
void printSingle(const T &value) {
    *out << value;
}

public:
Output(ostream &out) : out(&out) {}

inline void flush() {
    out->flush();
}

inline void print() {}

template<typename T, typename...Ts>
inline void print(const T &f, const Ts&... args) {
    printSingle(f);
    if (sizeof...(args) != 0) {
        *out << ' ';
        print(args...);
    }
}

template<typename...Ts>
inline void println(const Ts&... args) {
    print(args...);
    *out << '\n';
}

template<typename...Ts>
inline void operator() (const Ts&... args) {
    println(args...);
}

};

Output out(cout);

namespace template_util {

    constexpr int bytecount(uint64_t x) {
        return x ? 1 + bytecount(x >> 8) : 0;
    }

    template<int N>
    struct bytetype {

    };

    /// caide keep
    template<uint64_t N>
    struct minimal_uint : bytetype<bytecount(N)> {
    };
}

void solve(istream& inStream, ostream& outStream) {
    in = Input(inStream);
    out = Output(outStream);
    auto n = in.ni();
    auto m = in.ni();
    vec<string> f(n);
    FOR(i, n) {
        f[i] = in.ns();
    }
    int dx[] = {1, 0, -1, 0};
    int dy[] = {0, 1, 0, -1};
    string keys = "DRUL";
    bool checkRight = false, checkDown = false;

    vec<pair<int, int>> q;
    q.push_back({0, 0});
    vec2d<pair<int, int>> parent = makeVec2d<pair<int, int>>(n, m);
    parent[0][0] = {-1, -1};
    vec2d<int> used = makeVec2d<int>(n, m, false);
    used[0][0] = true;
    vec<pair<int, int>> path;
    FOR(qi, q.size()) {
        int x = q[qi].first, y = q[qi].second;
        if (f[x][y] == 'F') {
            while (x != -1) {
                path.push_back({x, y});
                auto pp = parent[x][y];
                x = pp.first;
                y = pp.second;
            }
            reverse(all(path));
            break;
        }
        FOR(d, 4) {
            int nx = x + dx[d], ny = y + dy[d];
            if (nx >= 0 && ny >= 0 && nx < n && ny < m) {
                if (!used[nx][ny] && f[nx][ny] != '*') {
                    parent[nx][ny] = {x, y};
                    q.push_back({nx, ny});
                    used[nx][ny] = true;
                }
            }
        }
    }

    auto pressDown = [&] () -> pair<int, int> {
        out(keys[0]);
        out.flush();
        auto x = in.ni() - 1;
        auto y = in.ni() - 1;
        return {x, y};
    };

    auto pressUp = [&] () -> pair<int, int> {
        out(keys[2]);
        out.flush();
        auto x = in.ni() - 1;
        auto y = in.ni() - 1;
        return {x, y};
    };

    auto pressRight = [&] () -> pair<int, int> {
        out(keys[1]);
        out.flush();
        auto x = in.ni() - 1;
        auto y = in.ni() - 1;
        return {x, y};
    };

    auto pressLeft = [&] () -> pair<int, int> {
        out(keys[3]);
        out.flush();
        auto x = in.ni() - 1;
        auto y = in.ni() - 1;
        return {x, y};
    };

    FR(i, 1, path.size() - 1) {
        int deltaX = path[i].first - path[i-1].first;
        int deltaY = path[i].second - path[i-1].second;
        if (deltaX != 0) {
            if (!checkDown) {
                auto p = pressDown();
                if (p == path[i-1]) {
                    swap(keys[0], keys[2]);
                    pressDown();
                }
                checkDown = true;

            } else {
                if (deltaX > 0) {
                    pressDown();
                } else {
                    pressUp();
                }
            }
        } else {
            if (!checkRight) {
                auto p = pressRight();
                if (p == path[i-1]) {
                    swap(keys[1], keys[3]);
                    pressRight();
                }
                checkRight = true;
            } else {
                if (deltaY > 0) {
                    pressRight();
                } else {
                    pressLeft();
                }
            }
        }
    }
}

//#include <fstream>

int main() {
//  ifstream fin("bridges.in");
//  ofstream fout("bridges.out");
//    Input in(in);
//    Output out(out);
    solve(cin, cout);
//  solve(fin, fout);
    return 0;
}


#include <bits/stdc++.h>
#define fi first
#define se second
#define getmax(x, y) if (x < y) x = y
#define getmin(x, y) if (x > y) x = y
#define rep(i,a,b) for(ll i = a; i <= b; i++)
#define repd(i,a,b) for(ll i = a; i >= b; i--)
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<double,double> pdd;

const ll N = 1e3;
const ll mod = 1e9 + 7;
const ll inf = 1e9;
int dx[] = {0, 0, -1, 1};
int dy[] = {1, -1, 0, 0};

char a[N][N];
int lr = -1, ud = -1, x, y, n, m, u, v;
pii vis[N][N];

int check(int x, int y){
	if (x == 0 || x == n+1 || y == 0 || y == m+1 || vis[x][y].fi || a[x][y] == '*') return 0;
	return 1;
}

void dfs(int x, int y, int u, int v){
	vis[x][y] = {u, v};
	rep(i, 0, 3){
		if (check(x + dx[i], y + dy[i])){
			dfs(x + dx[i], y + dy[i], x, y);
		}
	}
}

void go(int x, int y, int u, int v){
	if (u == x+1){
		if (ud) cout << "U" << endl;
		else
		cout << "D" << endl;
	}

	if (u == x-1){
		if (ud) cout << "D" << endl;
		else
		cout << "U" << endl;
	}

	if (v == y+1){
		if (lr) cout << "L" << endl;
		else
		cout << "R" << endl;
	}

	if (v == y-1){
		if (lr) cout << "R" << endl;
		else
		cout << "L" << endl;
	}
}

int get(int &x, int &y){
	cin >> x >> y;
	if (a[x][y] == 'F') return 1;
	return 0;
}

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

	cin >> n >> m;

	rep(i, 1, n)
		rep(j, 1, m){
			cin >> a[i][j];
			if (a[i][j] == 'F') {
				u = i;
				v = j;
			}
		}

	if (m > 1 && a[1][2] != '*'){
		cout << "R" << endl;
		if (get(x,y)) return 0;
		if (x == 1 && y == 2) lr = 0; else lr = 1;
		if (lr == 0) {
			cout << "L" << endl;
			if (get(x,y)) return 0;
		}
		if (n > 1){
			rep(i, 1, m){
				if (a[2][i] != '*'){
					cout << "D" << endl;
					if (get(x,y)) return 0;
					if (x == 2 && y == i){
						ud = 0;
					} else ud = 1;
					break;
				}
				if (lr) cout << "L" << endl; else
				cout << "R" << endl;
				if (get(x,y)) return 0;
			}
		} else ud = 0;
		dfs(u, v, u, v);
		for(;;){
			go(x, y, vis[x][y].fi, vis[x][y].se);
			if (get(x,y)) return 0;
		}
	}

	if (n > 1 && a[2][1] != '*'){
		cout << "D" << endl;
		if (get(x,y)) return 0;
		if (x == 2 && y == 1) ud = 0; else ud = 1;
		if (ud == 0) {
			cout << "U" << endl;
			if (get(x,y)) return 0;
		}
		if (m > 1){
			rep(i, 1, n){
				if (a[i][2] != '*'){
					cout << "R" << endl;
					if (get(x,y)) return 0;
					if (x == i && y == 2){
						lr = 0;
					} else lr = 1;
					break;
				}
				if (ud) cout << "U" << endl; else
				cout << "D" << endl;
				if (get(x,y)) return 0;
			}
		} else lr = 0;
		dfs(u, v, u, v);
		for(;;){
			go(x, y, vis[x][y].fi, vis[x][y].se);
			if (get(x,y)) return 0;
		}
		return 0;
	}
}


#include <bits/stdc++.h>
#define fi first
#define se second
#define getmax(x, y) if (x < y) x = y
#define getmin(x, y) if (x > y) x = y
#define rep(i,a,b) for(ll i = a; i <= b; i++)
#define repd(i,a,b) for(ll i = a; i >= b; i--)
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<double,double> pdd;

const ll N = 1e3;
const ll mod = 1e9 + 7;
const ll inf = 1e9;
int dx[] = {0, 0, -1, 1};
int dy[] = {1, -1, 0, 0};

char a[N][N];
int lr = -1, ud = -1, x, y, n, m, u, v;
pii vis[N][N];

int check(int x, int y){
	if (x == 0 || x == n+1 || y == 0 || y == m+1 || vis[x][y].fi || a[x][y] == '*') return 0;
	return 1;
}

void dfs(int x, int y, int u, int v){
	vis[x][y] = {u, v};
	rep(i, 0, 3){
		if (check(x + dx[i], y + dy[i])){
			dfs(x + dx[i], y + dy[i], x, y);
		}
	}
}

void go(int x, int y, int u, int v){
	if (u == x+1){
		if (ud) cout << "U" << endl;
		else
		cout << "D" << endl;
	}

	if (u == x-1){
		if (ud) cout << "D" << endl;
		else
		cout << "U" << endl;
	}

	if (v == y+1){
		if (lr) cout << "L" << endl;
		else
		cout << "R" << endl;
	}

	if (v == y-1){
		if (lr) cout << "R" << endl;
		else
		cout << "L" << endl;
	}
}
int  main(){
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
	cerr.tie(nullptr);

	cin >> n >> m;

	rep(i, 1, n)
		rep(j, 1, m){
			cin >> a[i][j];
			if (a[i][j] == 'F') {
				u = i;
				v = j;
			}
		}

	if (m > 1 && a[1][2] == '.'){
		cout << "R" << endl;
		cin >> x >> y;
		if (x == 1 && y == 2) lr = 0; else lr = 1;
		if (lr == 0) {
			cout << "L" << endl;
			cin >> x >> y;
		}
		if (n > 1){
			rep(i, 1, m){
				if (a[1][i] == 'F'){
					return 0;
				}
				if (a[2][i] == '.'){
					cout << "D" << endl;
					cin >> x >> y;
					if (x == 2 && y == i){
						ud = 0;
					} else ud = 1;
					break;
				}
				if (lr) cout << "L" << endl; else
				cout << "R" << endl;
				cin >> x >> y;
			}
		} else ud = 0;
		dfs(u, v, u, v);
		for(;;){
			go(x, y, vis[x][y].fi, vis[x][y].se);
			cin >> x >> y;
			if (x == u && y == v) return 0;
			if (x == 0 || y == 0) return 0;
		}
	}

	if (n > 1 && a[2][1] == '.'){
		cout << "D" << endl;
		cin >> x >> y;
		if (x == 2 && y == 1) ud = 0; else ud = 1;
		if (ud == 0) {
			cout << "U" << endl;
			cin >> x >> y;
		}
		if (m > 1){
			rep(i, 1, n){
				if (a[i][1] == 'F'){
					return 0;
				}
				if (a[i][2] == '.'){
					cout << "R" << endl;
					cin >> x >> y;
					if (x == i && y == 2){
						lr = 0;
					} else lr = 1;
					break;
				}
				if (ud) cout << "U" << endl; else
				cout << "D" << endl;
				cin >> x >> y;
			}
		} else lr = 0;
		dfs(u, v, u, v);
		for(;;){
			go(x, y, vis[x][y].fi, vis[x][y].se);
			cin >> x >> y;
			if (x == u && y == v) return 0;
			if (x == 0 || y == 0) return 0;
		}
	}
}


#include <bits/stdc++.h>
#define fi first
#define se second
#define getmax(x, y) if (x < y) x = y
#define getmin(x, y) if (x > y) x = y
#define rep(i,a,b) for(ll i = a; i <= b; i++)
#define repd(i,a,b) for(ll i = a; i >= b; i--)
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<double,double> pdd;

const ll N = 1e3;
const ll mod = 1e9 + 7;
const ll inf = 1e9;
int dx[] = {0, 0, -1, 1};
int dy[] = {1, -1, 0, 0};

char a[N][N];
int lr = -1, ud = -1, x, y, n, m, u, v;
pii vis[N][N];

int check(int x, int y){
	if (x == 0 || x == n+1 || y == 0 || y == m+1 || vis[x][y].fi || a[x][y] == '*') return 0;
	return 1;
}

void dfs(int x, int y, int u, int v){
	vis[x][y] = {u, v};
	rep(i, 0, 3){
		if (check(x + dx[i], y + dy[i])){
			dfs(x + dx[i], y + dy[i], x, y);
		}
	}
}

void go(int x, int y, int u, int v){
	if (u == x+1){
		if (ud) cout << "U" << endl;
		else
		cout << "D" << endl;
	}

	if (u == x-1){
		if (ud) cout << "D" << endl;
		else
		cout << "U" << endl;
	}

	if (v == y+1){
		if (lr) cout << "L" << endl;
		else
		cout << "R" << endl;
	}

	if (v == y-1){
		if (lr) cout << "R" << endl;
		else
		cout << "L" << endl;
	}
}

int get(int &x, int &y){
	cin >> x >> y;
	if (a[x][y] == 'F') return 1;
	return 0;
}

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

	cin >> n >> m;

	rep(i, 1, n)
		rep(j, 1, m){
			cin >> a[i][j];
			if (a[i][j] == 'F') {
				u = i;
				v = j;
			}
		}

	if (m > 1 && a[1][2] != '.'){
		cout << "R" << endl;
		if (get(x,y)) return 0;
		if (x == 1 && y == 2) lr = 0; else lr = 1;
		if (lr == 0) {
			cout << "L" << endl;
			if (get(x,y)) return 0;
		}
		if (n > 1){
			rep(i, 1, m){
				if (a[2][i] = '.'){
					cout << "D" << endl;
					if (get(x,y)) return 0;
					if (x == 2 && y == i){
						ud = 0;
					} else ud = 1;
					break;
				}
				if (lr) cout << "L" << endl; else
				cout << "R" << endl;
				if (get(x,y)) return 0;
			}
		} else ud = 0;
		dfs(u, v, u, v);
		for(;;){
			go(x, y, vis[x][y].fi, vis[x][y].se);
			if (get(x,y)) return 0;
		}
	}

	if (n > 1 && a[2][1] == '.'){
		cout << "D" << endl;
		if (get(x,y)) return 0;
		if (x == 2 && y == 1) ud = 0; else ud = 1;
		if (ud == 0) {
			cout << "U" << endl;
			if (get(x,y)) return 0;
		}
		if (m > 1){
			rep(i, 1, n){
				if (a[i][2] == '.'){
					cout << "R" << endl;
					if (get(x,y)) return 0;
					if (x == i && y == 2){
						lr = 0;
					} else lr = 1;
					break;
				}
				if (ud) cout << "U" << endl; else
				cout << "D" << endl;
				if (get(x,y)) return 0;
			}
		} else lr = 0;
		dfs(u, v, u, v);
		for(;;){
			go(x, y, vis[x][y].fi, vis[x][y].se);
			if (get(x,y)) return 0;
		}
		return 0;
	}
}


#include <bits/stdc++.h>
#define fi first
#define se second
#define getmax(x, y) if (x < y) x = y
#define getmin(x, y) if (x > y) x = y
#define rep(i,a,b) for(ll i = a; i <= b; i++)
#define repd(i,a,b) for(ll i = a; i >= b; i--)
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<double,double> pdd;

const ll N = 1e3;
const ll mod = 1e9 + 7;
const ll inf = 1e9;
int dx[] = {0, 0, -1, 1};
int dy[] = {1, -1, 0, 0};

char a[N][N];
int lr = -1, ud = -1, x, y, n, m, u, v;
pii vis[N][N];

int check(int x, int y){
	if (x == 0 || x == n+1 || y == 0 || y == m+1 || vis[x][y].fi || a[x][y] == '*') return 0;
	return 1;
}

void dfs(int x, int y, int u, int v){
	vis[x][y] = {u, v};
	rep(i, 0, 3){
		if (check(x + dx[i], y + dy[i])){
			dfs(x + dx[i], y + dy[i], x, y);
		}
	}
}

void go(int x, int y, int u, int v){
	if (u == x+1){
		if (ud) cout << "U" << endl;
		else
		cout << "D" << endl;
	}

	if (u == x-1){
		if (ud) cout << "D" << endl;
		else
		cout << "U" << endl;
	}

	if (v == y+1){
		if (lr) cout << "L" << endl;
		else
		cout << "R" << endl;
	}

	if (v == y-1){
		if (lr) cout << "R" << endl;
		else
		cout << "L" << endl;
	}
}
int  main(){
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
	cerr.tie(nullptr);

	cin >> n >> m;

	rep(i, 1, n)
		rep(j, 1, m){
			cin >> a[i][j];
			if (a[i][j] == 'F') {
				u = i;
				v = j;
			}
		}

	if (m > 1 && a[1][2] == '.'){
		cout << "R" << endl;
		cin >> x >> y;
		if (x == 1 && y == 2) lr = 0; else lr = 1;
		if (lr == 0) {
			cout << "L" << endl;
			cin >> x >> y;
		}
		if (n > 1){
			rep(i, 1, m){
				if (a[1][i] == 'F'){
					return 0;
				}
				if (a[2][i] == '.'){
					cout << "D" << endl;
					cin >> x >> y;
					if (x == 2 && y == i){
						ud = 0;
					} else ud = 1;
					break;
				}
				if (lr) cout << "L" << endl; else
				cout << "R" << endl;
				cin >> x >> y;
			}
		} else ud = 0;
		dfs(u, v, u, v);
		while (x != vis[x][y].fi || y != vis[x][y].se){
			go(x, y, vis[x][y].fi, vis[x][y].se);
			cin >> x >> y;
		}
		return 0;
	}

	if (n > 1 && a[2][1] == '.'){
		cout << "D" << endl;
		cin >> x >> y;
		if (x == 2 && y == 1) ud = 0; else ud = 1;
		if (ud == 0) {
			cout << "U" << endl;
			cin >> x >> y;
		}
		if (m > 1){
			rep(i, 1, n){
				if (a[i][1] == 'F'){
					return 0;
				}
				if (a[i][2] == '.'){
					cout << "R" << endl;
					cin >> x >> y;
					if (x == i && y == 2){
						lr = 0;
					} else lr = 1;
					break;
				}
				if (ud) cout << "U" << endl; else
				cout << "D" << endl;
				cin >> x >> y;
			}
		} else lr = 0;
		dfs(u, v, u, v);
		while (x != vis[x][y].fi || y != vis[x][y].se){
			go(x, y, vis[x][y].fi, vis[x][y].se);
			cin >> x >> y;
		}
		return 0;
	}
}


#include <bits/stdc++.h>
#define fi first
#define se second
#define getmax(x, y) if (x < y) x = y
#define getmin(x, y) if (x > y) x = y
#define rep(i,a,b) for(ll i = a; i <= b; i++)
#define repd(i,a,b) for(ll i = a; i >= b; i--)
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<double,double> pdd;

const ll N = 1e3;
const ll mod = 1e9 + 7;
const ll inf = 1e9;
int dx[] = {0, 0, -1, 1};
int dy[] = {1, -1, 0, 0};

char a[N][N];
int lr = -1, ud = -1, x = 1, y = 1, n, m, u, v;
pii vis[N][N];

int check(int x, int y){
	if (x == 0 || x == n+1 || y == 0 || y == m+1 || vis[x][y].fi || a[x][y] == '*') return 0;
	return 1;
}

void dfs(int x, int y, int u, int v){
	vis[x][y] = {u, v};
	rep(i, 0, 3){
		if (check(x + dx[i], y + dy[i])){
			dfs(x + dx[i], y + dy[i], x, y);
		}
	}
}

void go(int &x, int &y, int u, int v){

	if (u == x+1 || u == x-1){
		if (lr == -1){
			if (u == x+1) cout << "D" << endl; else cout << "U" << endl;
			cin >> x >> y;
			if (x != u || y != v) lr = 1; else lr = 0;
		}
		else {
			if (u == x+1){
				if (lr == 0) cout << "D" << endl; else cout << "U" << endl;
			} else {
				if (lr == 0) cout << "U" << endl; else cout << "D" << endl;
			}
			cin >> x >> y;
		}
	}

	if (v == y+1 || v == y-1){
		if (ud == -1){
			if (v == y+1) cout << "R" << endl; else cout << "L" << endl;
			cin >> x >> y;
			if (x != u || y != v) ud = 1; else ud = 0;
		}
		else {
			if (v == y+1){
				if (ud == 0) cout << "R" << endl; else cout << "L" << endl;
			} else {
				if (ud == 0) cout << "L" << endl; else cout << "R" << endl;
			}
			cin >> x >> y;
		}
	}

}

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

	cin >> n >> m;

	rep(i, 1, n)
		rep(j, 1, m){
			cin >> a[i][j];
			if (a[i][j] == 'F') {
				u = i;
				v = j;
			}
		}

	dfs(u, v, u, v);
	for (;;){
		go(x, y, vis[x][y].fi, vis[x][y].se);
		if (x == u && y == v) return 0;
	}
}


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

using pii = pair<int,int>;
#define f(i,a,b) for(int i=a;i<b;i++)
#define fr(i,a,b) for(int i=b-1;i>=a;i--)
#define IN(i,a,b) (a<=i&&i<=b)
#define pb push_back
#define flush fflush(stdout)

const int mxn = 100;
int n,m,x,y;
char board[mxn][mxn];
bool vis[mxn][mxn];
string Dir = "LRUD";
int di[] = {0,0,-1,1};
int dj[] = {-1,1,0,0};
vector<int> moves;

bool valid(int i, int j) {
	return IN(i,0,n-1)&&IN(j,0,m-1)&&!vis[i][j]&&board[i][j] != '*';
}

void invert() {
	f(i,0,n) f(j,i+1,m)
		swap(board[i][j],board[j][i]);
	swap(n,m);
	Dir = "UDLR";
}

void move(int i) {
	cout << Dir[i] << endl;
	flush;
	cin>>x>>y;
	x--;y--;
}

bool dfs(int i, int j) {
	if (board[i][j] == 'F') return 1;
	vis[i][j] = 1;
	f(k,0,4) {
		int ni = i+di[k], nj = j+dj[k];
		moves.pb(k);
		if (valid(ni,nj) && dfs(ni,nj)) return 1;
		moves.pop_back();
	}
	return 0;
}

const int DEBUG = 0;

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
#ifdef LOCAL
	if (DEBUG) freopen("input.txt", "r", stdin);
	if (DEBUG) freopen("output.txt", "w", stdout);
#endif
	cin>>n>>m;
	f(i,0,n) f(j,0,m) cin>>board[i][j];
	if (board[0][1] == '*')
		invert();
	f(i,0,n) f(j,0,m) vis[i][j]=0;
	x = 0, y = 0;
	move(0);
	if (y) swap(Dir[0],Dir[1]),move(0);
	while (board[1][y] == '*') {
		if (board[x][y] == 'F') return 0;
		move(1);
	}
	move(2);
	if (x) swap(Dir[2],Dir[3]);
	dfs(x,y);
	f(i,0,moves.size())
		move(moves[i]);
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
using pii = pair<int,int>;
#define f(i,a,b) for(int i=a;i<b;i++)
#define fr(i,a,b) for(int i=b-1;i>=a;i--)
#define IN(i,a,b) (a<=i&&i<=b)
#define pb push_back
#define flush fflush(stdout)
const int mxn = 100;
int n,m,x,y;
char board[mxn][mxn];
bool vis[mxn][mxn];
string Dir = "LRUD";
bool flipped=0;
int di[] = {0,0,-1,1};
int dj[] = {-1,1,0,0};
vector<int> moves;
bool valid(int i, int j) {
	return IN(i,0,n-1)&&IN(j,0,m-1)&&!vis[i][j]&&board[i][j] != '*';
}
void invert() {
	f(i,0,n) f(j,i+1,m)
		swap(board[i][j],board[j][i]);
	swap(n,m); flipped ^=1;
	Dir = "UDLR";
}
void move(int i) {
	cout << Dir[i] << endl;
	flush;
	cin>>x>>y;
	x--;y--;
	if (flipped) swap(x,y);
}
bool dfs(int i, int j) {
	if (board[i][j] == 'F') return 1;
	vis[i][j] = 1;
	f(k,0,4) {
		int ni = i+di[k], nj = j+dj[k];
		moves.pb(k);
		if (valid(ni,nj) && dfs(ni,nj)) return 1;
		moves.pop_back();
	}
	return 0;
}
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cin>>n>>m;
	f(i,0,n) f(j,0,m) cin>>board[i][j];
	if (board[0][1] == '*')
		invert();
	f(i,0,n) f(j,0,m) vis[i][j]=0;
	x = 0, y = 0;
	move(0);
	if (y) swap(Dir[0],Dir[1]),move(0);
	while (board[1][y] == '*') {
		if (board[x][y] == 'F') return 0;
		move(1);
	}
	move(2);
	if (x) swap(Dir[2],Dir[3]);
	dfs(x,y);
	f(i,0,moves.size())
		move(moves[i]);
	return 0;
}


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

using pii = pair<int,int>;
#define f(i,a,b) for(int i=a;i<b;i++)
#define fr(i,a,b) for(int i=b-1;i>=a;i--)
#define IN(i,a,b) (a<=i&&i<=b)
#define pb push_back
#define flush fflush(stdout)

const int mxn = 100;
int n,m,x,y;
char board[mxn][mxn];
bool vis[mxn][mxn];
bool flipped = 0;
string Dir = "LRUD";
int di[] = {0,0,-1,1};
int dj[] = {-1,1,0,0};
vector<int> moves;

bool valid(int i, int j) {
	return IN(i,0,n-1)&&IN(j,0,m-1)&&!vis[i][j]&&board[i][j] != '*';
}

void invert() {
	f(i,0,n) f(j,i+1,m)
		swap(board[i][j],board[j][i]);
	swap(n,m);
	flipped ^=1;
	Dir = "UDLR";
}

void move(int i) {
	cout << Dir[i] << endl;
	flush;
	cin>>x>>y;
	x--;y--;
	if (flipped) swap(x,y);
}

bool dfs(int i, int j) {
	if (board[i][j] == 'F') return 1;
	vis[i][j] = 1;
	f(k,0,4) {
		int ni = i+di[k], nj = j+dj[k];
		moves.pb(k);
		if (valid(ni,nj) && dfs(ni,nj)) return 1;
		moves.pop_back();
	}
	return 0;
}

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cin>>n>>m;
	f(i,0,n) f(j,0,m) cin>>board[i][j];
	if (board[0][1] == '*')
		invert();
	f(i,0,n) f(j,0,m) cout <<board[i][j]<<" \n"[j+1==m];
	f(i,0,n) f(j,0,m) vis[i][j]=0;
	x = 0, y = 0;
	move(0);
	if (y) swap(Dir[0],Dir[1]),move(0);
	while (board[1][y] == '*') {
		if (board[x][y] == 'F') return 0;
		move(1);
	}
	move(2);
	if (x) swap(Dir[2],Dir[3]);
	dfs(x,y);
	f(i,0,moves.size())
		move(moves[i]);
	return 0;
}


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

using pii = pair<int,int>;
#define f(i,a,b) for(int i=a;i<b;i++)
#define fr(i,a,b) for(int i=b-1;i>=a;i--)
#define IN(i,a,b) (a<=i&&i<=b)
#define pb push_back
#define flush fflush(stdout)

const int mxn = 100;
int n,m,x,y;
char board[mxn][mxn];
bool vis[mxn][mxn];
string Dir = "LRUD";
int di[] = {0,0,-1,1};
int dj[] = {-1,1,0,0};
vector<int> moves;

bool valid(int i, int j) {
	return IN(i,0,n-1)&&IN(j,0,m-1)&&!vis[i][j]&&board[i][j] != '*';
}

void invert() {
	f(i,0,n) f(j,i+1,m)
		swap(board[i][j],board[j][i]);
	swap(n,m);
	Dir = "UDLR";
}

void move(int i) {
	cout << Dir[i] << endl;
	flush;
	cin>>x>>y;
	x--;y--;
}

bool dfs(int i, int j) {
	if (board[i][j] == 'F') return 1;
	vis[i][j] = 1;
	f(k,0,4) {
		int ni = i+di[k], nj = j+dj[k];
		moves.pb(k);
		if (valid(ni,nj) && dfs(ni,nj)) return 1;
		moves.pop_back();
	}
	return 0;
}

const int DEBUG = 0;

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
#ifdef LOCAL
	if (DEBUG) freopen("input.txt", "r", stdin);
	if (DEBUG) freopen("output.txt", "w", stdout);
#endif
	cin>>n>>m;
	f(i,0,n) f(j,0,m) cin>>board[i][j];
	if (board[0][1] == '*')
		invert();
	f(i,0,n) f(j,0,m) vis[i][j]=0;
	x = 0, y = 0;
	move(0);
	if (y) swap(Dir[0],Dir[1]),move(0);
	while (board[1][y] == '*') move(1);
	move(2);
	if (x) swap(Dir[2],Dir[3]);
	dfs(x,y);
	f(i,0,moves.size())
		move(moves[i]);
	return 0;
}


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

using pii = pair<int,int>;
#define f(i,a,b) for(int i=a;i<b;i++)
#define fr(i,a,b) for(int i=b-1;i>=a;i--)
#define IN(i,a,b) (a<=i&&i<=b)
#define pb push_back
#define flush fflush(stdout)

const int mxn = 100;
int n,m,x,y;
bool flipped=0;
char board[mxn][mxn];
bool vis[mxn][mxn];
string Dir = "LRUD";
int di[] = {0,0,-1,1};
int dj[] = {-1,1,0,0};
vector<int> moves;

bool valid(int i, int j) {
	return IN(i,0,n-1)&&IN(j,0,m-1)&&!vis[i][j]&&board[i][j] != '*';
}

void invert() {
	f(i,0,n) f(j,i+1,m)
		swap(board[i][j],board[j][i]);
	swap(n,m); flipped^=1;
	Dir = "UDLR";
}

void move(int i) {
	cout << Dir[i] << endl;
	flush;
	cin>>x>>y;
	if (flipped) swap(x,y);
	x--;y--;
}

bool dfs(int i, int j) {
	if (board[i][j] == 'F') return 1;
	vis[i][j] = 1;
	f(k,0,4) {
		int ni = i+di[k], nj = j+dj[k];
		moves.pb(k);
		if (valid(ni,nj) && dfs(ni,nj)) return 1;
		moves.pop_back();
	}
	return 0;
}

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cin>>n>>m;
	f(i,0,n) f(j,0,m) cin>>board[i][j];
	if (board[0][1] == '*')
		invert();
	f(i,0,n) f(j,0,m) vis[i][j]=0;
	x = 0, y = 0;
	move(0);
	if (y) swap(Dir[0],Dir[1]),move(0);
	while (board[1][y] == '*') {
		if (board[x][y] == 'F') return 0;
		move(1);
	}
	move(2);
	if (x) swap(Dir[2],Dir[3]);
	dfs(x,y);
	f(i,0,moves.size())
		move(moves[i]);
	return 0;
}