#define _CRT_SECURE_NO_WARNINGS
#include<istream>
#include<string.h>
#define HASH_LEN 300000
using namespace std;
typedef long long int ll;
int set[HASH_LEN][4];
char seq[400004];
int dxdy[4][2] = { {-1,0},{1,0},{0,1},{0,-1} };
int* direct(char c) {
	switch (c) {
	case 'L':
		return dxdy[0];
	case 'R':
		return dxdy[1];
	case 'U':
		return dxdy[2];
	case 'D':
		return dxdy[3];
	}
}

int main() {
	int TC;
	scanf("%d", &TC);
	for (int tc = 0; tc < TC; tc++) {
		int n = 0;
		scanf("%d", &n);
		scanf("%s", &seq);
		ll curX = 0, curY = 0;

		memset(set, -1, sizeof(set));

		set[0][0] = 0, set[0][1] = 0, set[0][2] = 0, set[0][3] = 0;

		int minLen = 0xFFFFFFF, l = -1, r = -1;

		for (int i = 1; i <= n; i++) {
			curX += direct(seq[i - 1])[0];
			curY += direct(seq[i - 1])[1];
			int _key = (curX*curX + curY * curY) % HASH_LEN;
			while (set[_key][0] != -1) {
				if (set[_key][1] == curY && set[_key][2] == curX)
					break;
				_key = (_key + 1) % HASH_LEN;
			}
			if (set[_key][0] == -1) {
				set[_key][0] = _key;
				set[_key][1] = curY, set[_key][2] = curX;
				set[_key][3] = i;
			}
			else {
				if (minLen > i - set[_key][3]) {
					minLen = i - set[_key][3];
					l = set[_key][3] + 1;
					r = i;
				}
				set[_key][3] = i;
			}
		}
		if (l < 0)
			printf("-1\n");
		else
			printf("%d %d\n", l, r);
	}
	return 0;
}


#define _CRT_SECURE_NO_WARNINGS
#include<istream>
#include<string.h>
#define HASH_LEN 300000
using namespace std;
typedef long long int ll;
int set[HASH_LEN][4];
char seq[400004];
char buf[100];

int dxdy[4][2] = { {-1,0},{1,0},{0,1},{0,-1} };
int* direct(char c) {
	switch (c) {
	case 'L':
		return dxdy[0];
	case 'R':
		return dxdy[1];
	case 'U':
		return dxdy[2];
	case 'D':
		return dxdy[3];
	}
}
inline unsigned long _hash(char *str)
{
	unsigned long hash = 5381;
	register int c;
	while (c = *str++) hash = ((hash << 5) + hash) + c;
	return hash;
}
int main() {
	int TC;
	scanf("%d", &TC);
	for (int tc = 0; tc < TC; tc++) {
		int n = 0;
		scanf("%d", &n);
		scanf("%s", &seq);
		int curX = 0, curY = 0;

		memset(set, -1, sizeof(set));
		sprintf(buf, "%d %d", 0, 0);
		int _key = 0;
		set[_key][0] = _key, set[_key][1] = 0, set[_key][2] = 0, set[_key][3] = 0;

		int minLen = 0xFFFFFFF, l = -1, r = -1;
		for (int i = 1; i <= n; i++) {
			curX += direct(seq[i - 1])[0];
			curY += direct(seq[i - 1])[1];

			int _key = ((unsigned int)(curX*curX*curX + curY * curY*curY)) % HASH_LEN;
			while (set[_key][0] != -1) {
				if (set[_key][1] == curY && set[_key][2] == curX)
					break;
				_key = (_key + 1) % HASH_LEN;
			}
			if (set[_key][0] == -1) {
				set[_key][0] = _key;
				set[_key][1] = curY, set[_key][2] = curX;
				set[_key][3] = i;
			}
			else {
				if (minLen > i - set[_key][3]) {
					minLen = i - set[_key][3];
					l = set[_key][3] + 1;
					r = i;
				}
				set[_key][3] = i;
			}
		}
		if (l < 0)
			printf("-1\n");
		else
			printf("%d %d\n", l, r);
	}
	return 0;
}


#define _CRT_SECURE_NO_WARNINGS
#include<istream>
#include<string.h>
#define HASH_LEN 300000
using namespace std;
typedef long long int ll;
int set[HASH_LEN][4];
char seq[400004];
char buf[20010];

int dxdy[4][2] = { {-1,0},{1,0},{0,1},{0,-1} };
int* direct(char c) {
	switch (c) {
	case 'L':
		return dxdy[0];
	case 'R':
		return dxdy[1];
	case 'U':
		return dxdy[2];
	case 'D':
		return dxdy[3];
	}
}
inline unsigned long _hash(char *str)
{
	unsigned long hash = 5381;
	register int c;
	while (c = *str++) hash = ((hash << 5) + hash) + c;
	return hash;
}
int main() {
	int TC;
	scanf("%d", &TC);
	for (int tc = 0; tc < TC; tc++) {
		int n = 0;
		scanf("%d", &n);
		scanf("%s", &seq);
		int curX = 0, curY = 0;

		memset(set, -1, sizeof(set));

		set[0][0] = 0, set[0][1] = 0, set[0][2] = 0, set[0][3] = 0;

		int minLen = 0xFFFFFFF, l = -1, r = -1;
		for (int i = 1; i <= n; i++) {
			curX += direct(seq[i - 1])[0];
			curY += direct(seq[i - 1])[1];

			sprintf(buf,"%d %d", curX, curY);

			int _key = _hash(buf) % HASH_LEN;
			while (set[_key][0] != -1) {
				if (set[_key][1] == curY && set[_key][2] == curX)
					break;
				_key = (_key + 1) % HASH_LEN;
			}
			if (set[_key][0] == -1) {
				set[_key][0] = _key;
				set[_key][1] = curY, set[_key][2] = curX;
				set[_key][3] = i;
			}
			else {
				if (minLen > i - set[_key][3]) {
					minLen = i - set[_key][3];
					l = set[_key][3] + 1;
					r = i;
				}
				set[_key][3] = i;
			}
		}
		if (l < 0)
			printf("-1\n");
		else
			printf("%d %d\n", l, r);
	}
	return 0;
}


#define _CRT_SECURE_NO_WARNINGS
#include<istream>
#include<string.h>
#define HASH_LEN 300000
using namespace std;
typedef long long int ll;
ll set[HASH_LEN][4];
char seq[200004];
ll dxdy[4][2] = { {-1,0},{1,0},{0,1},{0,-1} };
ll* direct(char c) {
	switch (c) {
	case 'L':
		return dxdy[0];
	case 'R':
		return dxdy[1];
	case 'U':
		return dxdy[2];
	case 'D':
		return dxdy[3];
	}
}

int main() {
	int TC;
	scanf("%d", &TC);
	for (int tc = 0; tc < TC; tc++) {
		int n = 0;
		scanf("%d", &n);
		scanf("%s", &seq);
		ll curX = 0, curY = 0;

		memset(set, -1, sizeof(set));

		set[0][0] = 0, set[0][1] = 0, set[0][2] = 0, set[0][3] = 0;

		ll minLen = 0x7FFFFFFF, l = -1, r = -1;

		for (int i = 1; i <= n; i++) {
			curX += direct(seq[i - 1])[0];
			curY += direct(seq[i - 1])[1];

			ll _key = ((ll)(curY * (ll)curY) + ((ll)curX * (ll)curX)) % ((ll)HASH_LEN);
			if((int)_key < 0 )
				printf("err %llu %llu", curY, curX);
			while (set[_key][0] != -1) {
				if (set[_key][1] == curY && set[_key][2] == curX)
					break;
				_key = (_key + 1) % HASH_LEN;
			}

			if (set[_key][0] == -1) {
				set[_key][0] = _key;
				set[_key][1] = curY, set[_key][2] = curX;
				set[_key][3] = i;
			}
			else {
				if (minLen > i - set[_key][3]) {
					minLen = i - set[_key][3];
					l = set[_key][3] + 1;
					r = i;
				}
			}
		}
		if (l < 0)
			printf("-1\n");
		else
			printf("%llu %llu\n", l, r);
	}
	return 0;
}


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

int dxdy[4][2] = { {-1,0},{1,0},{0,1},{0,-1} };
char seq[200002];
int acc[200002][2];
int temp[2];
inline int* direct(char c) {
	switch (c) {
		case 'L':
			return dxdy[0];
		case 'R':
			return dxdy[1];
		case 'U':
			return dxdy[2];
		case 'D':
			return dxdy[3];
	}
}

int * sum(int l, int r) {
	temp[0] = acc[r][0] - acc[l][0];
	temp[1] = acc[r][1] - acc[l][1];
	return temp;
}

int main() {
	int TC;
	scanf("%d", &TC);
	for (int tc = 0; tc < TC; tc++) {
		int n = 0;
		scanf("%d", &n);
		scanf("%s", &seq);
		for (int i = 1; i <= n; i++) {
			acc[i][0] = acc[i - 1][0] + direct(seq[i - 1])[0];
			acc[i][1] = acc[i - 1][1] + direct(seq[i - 1])[1];
		}
		int l=-1, r = -1;
		for (int si = 2; si <= n; si += 2) {
			int found = 0;
			for (int s = 0; s + si <= n; s++) {
				sum(s, s + si);
				if (!temp[0] && !temp[1]) {
					found = 1;
					l = s, r = s + si;
					break;
				}
			}
			if (found) break;
		}
		if(l<0)
			printf("-1\n");
		else
			printf("%d %d\n", l+1, r);
	}
	return 0;
}


#define _CRT_SECURE_NO_WARNINGS
#include<istream>
#include<string.h>
#define HASH_LEN 300000
using namespace std;
typedef long long int ll;
int set[HASH_LEN][4];
char seq[400004];
int dxdy[4][2] = { {-1,0},{1,0},{0,1},{0,-1} };
int* direct(char c) {
	switch (c) {
	case 'L':
		return dxdy[0];
	case 'R':
		return dxdy[1];
	case 'U':
		return dxdy[2];
	case 'D':
		return dxdy[3];
	}
}

int main() {
	int TC;
	scanf("%d", &TC);
	for (int tc = 0; tc < TC; tc++) {
		int n = 0;
		scanf("%d", &n);
		scanf("%s", &seq);
		int curX = 0, curY = 0;

		memset(set, -1, sizeof(set));

		set[0][0] = 0, set[0][1] = 0, set[0][2] = 0, set[0][3] = 0;

		int minLen = 0xFFFFFFF, l = -1, r = -1;

		for (int i = 1; i <= n; i++) {
			curX += direct(seq[i - 1])[0];
			curY += direct(seq[i - 1])[1];

			int _key = (int)((((curY * (ll)curY) << 32) + (curX * (ll)curX)) % ((ll)HASH_LEN));
			while (set[_key][0] != -1) {
				if (set[_key][1] == curY && set[_key][2] == curX)
					break;
				_key = (_key + 1) % HASH_LEN;
			}
			if (set[_key][0] == -1) {
				set[_key][0] = _key;
				set[_key][1] = curY, set[_key][2] = curX;
				set[_key][3] = i;
			}
			else {
				if (minLen > i - set[_key][3]) {
					minLen = i - set[_key][3];
					l = set[_key][3] + 1;
					r = i;
				}
				set[_key][3] = i;
			}
		}
		if (l < 0)
			printf("-1\n");
		else
			printf("%d %d\n", l, r);
	}
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
    int i,j,n,k,l;
    int arr[20020][10];
    string st;
    map<pair<int,int>,int> mp;
    pair<int,int>pr;
    map<pair<int,int>,int>::iterator it;
    cin>>k;
    while(k--)
    {
        cin>>n>>st;
        arr[0][0]=0;
        arr[0][1]=0;
        for(i=1; i<=n; i++)
        {
            if(st[i-1]=='L')
            {
                arr[i][1]=arr[i-1][1];
                arr[i][0]=arr[i-1][0]-1;
            }
            else if(st[i-1]=='R')
            {
                arr[i][1]=arr[i-1][1];
                arr[i][0]=arr[i-1][0]+1;
            }
            else if(st[i-1]=='U')
            {
                arr[i][0]=arr[i-1][0];
                arr[i][1]=arr[i-1][1]+1;
            }
            else if(st[i-1]=='D')
            {
                arr[i][0]=arr[i-1][0];
                arr[i][1]=arr[i-1][1]-1;
            }
        }
        int m=9999999,f=0,p;
        for(i=0; i<=n; i++)
        {

            pr.first=arr[i][0];
            pr.second=arr[i][1];//cout<<pr.first<<" "<<pr.second<<endl;
            //it=mp.find(pr);

            if(mp.find(pr)!=mp.end())
            {
                if(m>i-(mp[pr]+2))
                {
                    m=i-(mp[pr]+2);
                    p=mp[pr]+1;
                    f=i;
                }
            }
            mp[pr]=i;
        }
        mp.clear();
//        for(it=mp.begin();it!=mp.end();it++)
//            cout<<it->first.first<<" "<<it->first.second<<" "<<it->second <<endl;
        if(m!=9999999)
        {
            cout<<p<<" "<<f<<endl;
        }
        else
            cout<<-1<<endl;
    }
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
    int i,j,n,k,l;
    int arr[200200][10];string st;map<pair<int,int>,int> mp;pair<int,int>pr;
    map<pair<int,int>,int>::iterator it;
    cin>>k;
    while(k--)
    {
        cin>>n>>st;arr[0][0]=0;arr[0][1]=0;
        for(i=1;i<=n;i++)
        {
            if(st[i-1]=='L')
            {
                arr[i][1]=arr[i-1][1];
                arr[i][0]=arr[i-1][0]-1;
            }
            else if(st[i-1]=='R')
            {arr[i][1]=arr[i-1][1];
                arr[i][0]=arr[i-1][0]+1;
            }
            else if(st[i-1]=='U')
            {arr[i][0]=arr[i-1][0];
                arr[i][1]=arr[i-1][1]+1;
            }
            else if(st[i-1]=='D')
            {arr[i][0]=arr[i-1][0];
                arr[i][1]=arr[i-1][1]-1;
            }
        }int m=9999999,f=0,p;
        for(i=0;i<=n;i++)
        {

            pr.first=arr[i][0];pr.second=arr[i][1];//cout<<pr.first<<" "<<pr.second<<endl;
            //it=mp.find(pr);
            if(mp.find(pr)==mp.end())
            {
                mp[pr]=i;
            }
            else if(m>i-(mp[pr]+2))
            {m=i-(mp[pr]+2);
                p=mp[pr]+1;f=i;
            }
        }mp.clear();
//        for(it=mp.begin();it!=mp.end();it++)
//            cout<<it->first.first<<" "<<it->first.second<<" "<<it->second <<endl;
        if(m!=9999999)
        {
            cout<<p<<" "<<f<<endl;
        }
        else cout<<-1<<endl;
    }
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
    int i,j,n,k,l;
    int arr[20020][10];string st;map<pair<int,int>,int> mp;pair<int,int>pr;
    map<pair<int,int>,int>::iterator it;
    cin>>k;
    while(k--)
    {
        cin>>n>>st;arr[0][0]=0;arr[0][1]=0;
        for(i=1;i<=n;i++)
        {
            if(st[i-1]=='L')
            {
                arr[i][1]=arr[i-1][1];
                arr[i][0]=arr[i-1][0]-1;
            }
            else if(st[i-1]=='R')
            {arr[i][1]=arr[i-1][1];
                arr[i][0]=arr[i-1][0]+1;
            }
            else if(st[i-1]=='U')
            {arr[i][0]=arr[i-1][0];
                arr[i][1]=arr[i-1][1]+1;
            }
            else if(st[i-1]=='D')
            {arr[i][0]=arr[i-1][0];
                arr[i][1]=arr[i-1][1]-1;
            }
        }int m=9999999,f=0,p;
        for(i=0;i<=n;i++)
        {

            pr.first=arr[i][0];pr.second=arr[i][1];//cout<<pr.first<<" "<<pr.second<<endl;
            //it=mp.find(pr);
            if(mp.find(pr)==mp.end())
            {
                mp[pr]=i;
            }
            else if(m>i-(mp[pr]+1))
            {m=i-(mp[pr]+1);
                p=mp[pr]+1;f=i;
            }
        }mp.clear();
//        for(it=mp.begin();it!=mp.end();it++)
//            cout<<it->first.first<<" "<<it->first.second<<" "<<it->second <<endl;
        if(m!=9999999)
        {
            cout<<p<<" "<<f<<endl;
        }
        else cout<<-1<<endl;
    }
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
    int i,j,n,k,l;
    int arr[20020][10];string st;map<pair<int,int>,int> mp;pair<int,int>pr;
    map<pair<int,int>,int>::iterator it;
    cin>>k;
    while(k--)
    {
        cin>>n>>st;arr[0][0]=0;arr[0][1]=0;
        for(i=1;i<=n;i++)
        {
            if(st[i-1]=='L')
            {
                arr[i][1]=arr[i-1][1];
                arr[i][0]=arr[i-1][0]-1;
            }
            else if(st[i-1]=='R')
            {arr[i][1]=arr[i-1][1];
                arr[i][0]=arr[i-1][0]+1;
            }
            else if(st[i-1]=='U')
            {arr[i][0]=arr[i-1][0];
                arr[i][1]=arr[i-1][1]+1;
            }
            else if(st[i-1]=='D')
            {arr[i][0]=arr[i-1][0];
                arr[i][1]=arr[i-1][1]-1;
            }
        }int m=9999999,f=0,p;
        for(i=0;i<=n;i++)
        {

            pr.first=arr[i][0];pr.second=arr[i][1];//cout<<pr.first<<" "<<pr.second<<endl;
            //it=mp.find(pr);
            if(mp.find(pr)==mp.end())
            {
                mp[pr]=i;
            }
            else if(m>i-(mp[pr]+2))
            {m=i-(mp[pr]+2);
                p=mp[pr]+1;f=i;
            }
        }mp.clear();
//        for(it=mp.begin();it!=mp.end();it++)
//            cout<<it->first.first<<" "<<it->first.second<<" "<<it->second <<endl;
        if(m!=9999999)
        {
            cout<<p<<" "<<f<<endl;
        }
        else cout<<-1<<endl;
    }
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
    int i,j,n,k,l;
    int arr[200200][10];
    string st;
    map<pair<int,int>,int> mp;
    pair<int,int>pr;
    map<pair<int,int>,int>::iterator it;
    cin>>k;
    while(k--)
    {
        cin>>n>>st;
        arr[0][0]=0;
        arr[0][1]=0;
        for(i=1; i<=n; i++)
        {
            if(st[i-1]=='L')
            {
                arr[i][1]=arr[i-1][1];
                arr[i][0]=arr[i-1][0]-1;
            }
            else if(st[i-1]=='R')
            {
                arr[i][1]=arr[i-1][1];
                arr[i][0]=arr[i-1][0]+1;
            }
            else if(st[i-1]=='U')
            {
                arr[i][0]=arr[i-1][0];
                arr[i][1]=arr[i-1][1]+1;
            }
            else if(st[i-1]=='D')
            {
                arr[i][0]=arr[i-1][0];
                arr[i][1]=arr[i-1][1]-1;
            }
        }
        int m=9999999,f=0,p;
        for(i=0; i<=n; i++)
        {

            pr.first=arr[i][0];
            pr.second=arr[i][1];//cout<<pr.first<<" "<<pr.second<<endl;
            //it=mp.find(pr);

            if(mp.find(pr)!=mp.end())
            {
                if(m>i-(mp[pr]+2))
                {
                    m=i-(mp[pr]+2);
                    p=mp[pr]+1;
                    f=i;
                }
            }
            mp[pr]=i;
        }
        mp.clear();
//        for(it=mp.begin();it!=mp.end();it++)
//            cout<<it->first.first<<" "<<it->first.second<<" "<<it->second <<endl;
        if(m!=9999999)
        {
            cout<<p<<" "<<f<<endl;
        }
        else
            cout<<-1<<endl;
    }
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
    int i,j,n,k,l;
    int arr[200200][10];string st;map<pair<int,int>,int> mp;pair<int,int>pr;
    map<pair<int,int>,int>::iterator it;
    cin>>k;
    while(k--)
    {
        cin>>n>>st;arr[0][0]=0;arr[0][1]=0;
        for(i=1;i<=n;i++)
        {
            if(st[i-1]=='L')
            {
                arr[i][1]=arr[i-1][1];
                arr[i][0]=arr[i-1][0]-1;
            }
            else if(st[i-1]=='R')
            {arr[i][1]=arr[i-1][1];
                arr[i][0]=arr[i-1][0]+1;
            }
            else if(st[i-1]=='U')
            {arr[i][0]=arr[i-1][0];
                arr[i][1]=arr[i-1][1]+1;
            }
            else if(st[i-1]=='D')
            {arr[i][0]=arr[i-1][0];
                arr[i][1]=arr[i-1][1]-1;
            }
        }int m=9999999,f=0,p;
        for(i=0;i<=n;i++)
        {

            pr.first=arr[i][0];pr.second=arr[i][1];//cout<<pr.first<<" "<<pr.second<<endl;
            //it=mp.find(pr);
            if(mp.find(pr)==mp.end())
            {
                mp[pr]=i;
            }
            else if(m>i-(mp[pr]+1))
            {m=i-(mp[pr]+1);
                p=mp[pr]+1;f=i;
            }
        }mp.clear();
//        for(it=mp.begin();it!=mp.end();it++)
//            cout<<it->first.first<<" "<<it->first.second<<" "<<it->second <<endl;
        if(m!=9999999)
        {
            cout<<p<<" "<<f<<endl;
        }
        else cout<<-1<<endl;
    }
}


#include <bits/stdc++.h>
using namespace std;
#define fast                      \
    ios_base::sync_with_stdio(0); \
    cin.tie(NULL)
#define fr(i, a, b) for (ll i = a; i < b; i++)
#define fr1(i, n, a) for (ll i = n - 1; i >= a; i--)
#define vi vector<ll>
#define vvi vector<vector<ll>>
typedef long long ll;
#define pb push_back
#define mod 1000000007
#define sz(x) (long long)(x).size()
#define trace(x) cerr << #x << ": " << x << endl;
#define endl "\n";

//const ll mod= 998244353;
ll zero = 0;
ll modmulti(ll a, ll b)
{
    return ((a % mod) * 1ll * (b % mod)) % mod;
}
ll modadd(ll a, ll b)
{
    ll asdfgh = ((a % mod) + (b % mod) + mod + mod) % mod;
    asdfgh = (asdfgh + mod) % mod;
    return asdfgh;
}
ll modpower(ll a, ll n)
{
    if (n == 0)
        return 1;
    if (n == 1)
        return a % mod;
    ll b = modpower(a, n / 2);
    b = modmulti(b, b);
    if (n % 2 == 0)
        return b;
    return modmulti(a, b);
}
ll gcd(ll a, ll b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);
}
ll modinv(ll a)
{
    return modpower(a, mod - 2);
}
ll lcm(ll a, ll b)
{
    return (a * b) / gcd(a, b);
}

void err()
{
    cout << "-1\n";
    return;
}

template <typename ForwardIterator, typename T>
ForwardIterator first_less_than(ForwardIterator first, ForwardIterator last, T value)
{
    auto it = std::lower_bound(first, last, value);
    return (it == first ? last : --it);
}
const int N = 2 * 1e5 + 5;
//vector<ll> adj[N];
//ll level[N]={-1},parent[N],color[N];
struct vertex
{
    ll parent;
    ll rank;
    ll comp;
    vi vec;
};

typedef struct vertex vertex;

vertex ver[N];

ll find(ll n)
{
    ll x = n;
    while (x != ver[x].parent)
    {
        x = ver[x].parent;
    }
    ll y = n;
    ll z = ver[y].parent;
    while (y != z)
    {
        ver[y].parent = x;
        y = z;
        z = ver[z].parent;
    }
    return x;
}

void makeset(ll n)
{
    ver[n].rank = 0;
    ver[n].parent = n;
    ver[n].comp = 1;
    ver[n].vec.pb(n);
}

void initiate(ll n)
{
    fr(i, 0, n) makeset(i);
}

void join(vi &x, vi &y)
{
    x.insert(x.end(), y.begin(), y.end());
}

void uni(ll x, ll y)
{
    ll px = find(x);
    ll py = find(y);
    if (px == py)
        return;
    else if (ver[px].rank > ver[py].rank)
    {
        ver[py].parent = px;
        ver[px].comp += ver[py].comp;
        join(ver[px].vec, ver[py].vec);
    }
    else if (ver[py].rank > ver[px].rank)
    {
        ver[px].parent = py;
        ver[py].comp += ver[px].comp;
        join(ver[py].vec, ver[px].vec);
    }
    else
    {
        ver[py].parent = px;
        ver[px].rank++;
        ver[px].comp += ver[py].comp;
        join(ver[px].vec, ver[py].vec);
    }
}
set<ll> s;
void primeFactors(ll n)
{
    while (n % 2 == 0)
    {
        s.insert(2);
        n = n / 2;
    }
    for (ll i = 3; i <= sqrt(n); i = i + 2)
    {

        while (n % i == 0)
        {
            s.insert(i);
            n = n / i;
        }
    }
    if (n > 2)
        s.insert(n);
}

int main()
{
    ll t;ll sum=0;
    cin>>t;
    while(t-->0){
        int n;
        cin>>n;
        char vect[n+2];ll temp=0,max=0,ii=0,jj=0,minj=0,mini=0;
        int a[2*n+2][2*n+2]= {{0}};int currx=n+1;int curry=n+1;a[currx][curry]=1;
        string s;
        int size = sizeof(vect)/sizeof(vect[0]);
        cin>>vect;
        fr(i,0,n){
            if(vect[i]=='\0')
                break;

            if(vect[i]=='L')
                currx--;

            if(vect[i]=='R')
                currx++;
            if(vect[i]=='U')
                curry++;
            if(vect[i]=='D')
                curry--;
            if(a[currx][curry]!=0){
                ii=a[currx][curry];
                jj=i+2;
                if(jj-ii<max || max==0){
                    max=jj-ii;
                    minj=jj;
                    mini=ii;
                }

            }
             a[currx][curry]=i+2;

        }

        if(mini==0 and minj==0){
               cout<<-1<<endl;}
            else{
                 cout<<mini;
                 cout<<" ";
                 cout<<minj-1<<endl;
    }
    }

    return 0;
}

//cerr << "Time elapsed:" << clock() / (double)CLOCKS_PER_SEC << endl;
//return 0;


#include <bits/stdc++.h>
using namespace std;
#define fast                      \
    ios_base::sync_with_stdio(0); \
    cin.tie(NULL)
#define fr(i, a, b) for (ll i = a; i < b; i++)
#define fr1(i, n, a) for (ll i = n - 1; i >= a; i--)
#define vi vector<ll>
#define vvi vector<vector<ll>>
typedef long long ll;
#define pb push_back
#define mod 1000000007
#define sz(x) (long long)(x).size()
#define trace(x) cerr << #x << ": " << x << endl;
#define endl "\n";

//const ll mod= 998244353;
ll zero = 0;
ll modmulti(ll a, ll b)
{
    return ((a % mod) * 1ll * (b % mod)) % mod;
}
ll modadd(ll a, ll b)
{
    ll asdfgh = ((a % mod) + (b % mod) + mod + mod) % mod;
    asdfgh = (asdfgh + mod) % mod;
    return asdfgh;
}
ll modpower(ll a, ll n)
{
    if (n == 0)
        return 1;
    if (n == 1)
        return a % mod;
    ll b = modpower(a, n / 2);
    b = modmulti(b, b);
    if (n % 2 == 0)
        return b;
    return modmulti(a, b);
}
ll gcd(ll a, ll b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);
}
ll modinv(ll a)
{
    return modpower(a, mod - 2);
}
ll lcm(ll a, ll b)
{
    return (a * b) / gcd(a, b);
}

void err()
{
    cout << "-1\n";
    return;
}

template <typename ForwardIterator, typename T>
ForwardIterator first_less_than(ForwardIterator first, ForwardIterator last, T value)
{
    auto it = std::lower_bound(first, last, value);
    return (it == first ? last : --it);
}
const int N = 2 * 1e5 + 5;
//vector<ll> adj[N];
//ll level[N]={-1},parent[N],color[N];
struct vertex
{
    ll parent;
    ll rank;
    ll comp;
    vi vec;
};

typedef struct vertex vertex;

vertex ver[N];

ll find(ll n)
{
    ll x = n;
    while (x != ver[x].parent)
    {
        x = ver[x].parent;
    }
    ll y = n;
    ll z = ver[y].parent;
    while (y != z)
    {
        ver[y].parent = x;
        y = z;
        z = ver[z].parent;
    }
    return x;
}

void makeset(ll n)
{
    ver[n].rank = 0;
    ver[n].parent = n;
    ver[n].comp = 1;
    ver[n].vec.pb(n);
}

void initiate(ll n)
{
    fr(i, 0, n) makeset(i);
}

void join(vi &x, vi &y)
{
    x.insert(x.end(), y.begin(), y.end());
}

void uni(ll x, ll y)
{
    ll px = find(x);
    ll py = find(y);
    if (px == py)
        return;
    else if (ver[px].rank > ver[py].rank)
    {
        ver[py].parent = px;
        ver[px].comp += ver[py].comp;
        join(ver[px].vec, ver[py].vec);
    }
    else if (ver[py].rank > ver[px].rank)
    {
        ver[px].parent = py;
        ver[py].comp += ver[px].comp;
        join(ver[py].vec, ver[px].vec);
    }
    else
    {
        ver[py].parent = px;
        ver[px].rank++;
        ver[px].comp += ver[py].comp;
        join(ver[px].vec, ver[py].vec);
    }
}
set<ll> s;
void primeFactors(ll n)
{
    while (n % 2 == 0)
    {
        s.insert(2);
        n = n / 2;
    }
    for (ll i = 3; i <= sqrt(n); i = i + 2)
    {

        while (n % i == 0)
        {
            s.insert(i);
            n = n / i;
        }
    }
    if (n > 2)
        s.insert(n);
}

int main()
{
    ll t;ll sum=0;

    fast;

    cin>>t;
    while(t-->0){
        ll n;
        cin>>n;
        char vect[n+2];ll temp=0,max=0,ii=0,jj=0,minj=0,mini=0;
        map<pair<int, int>, int> a;
        pair<int, int> cur = {0, 0};
        cur.first=0;cur.second=0;a[cur]=1;
        string s;
        cin>>vect;

        fr(i,0,n){

            if(vect[i]=='L')
                cur.first--;
            else if(vect[i]=='R')
                cur.first++;
            else if(vect[i]=='U')
                cur.second++;
            else if(vect[i]=='D')
                cur.second--;

            if(a.count(cur)){
                ii=a[cur];
                jj=i+2;
                if(jj-ii<max || max==0){
                    max=jj-ii;
                    minj=jj;
                    mini=ii;
                }

            }
            a[cur]=i+2;
        }

        if(mini==0 and minj==0){
               cout<<-1<<endl;
               }
            else{
                 cout<<mini;
                 cout<<" ";
                 cout<<minj-1<<endl;
    }
    }

    return 0;
}
//    cerr << "Time elapsed: " << clock() / (double)CLOCKS_PER_SEC << endl;
//return 0;


#include <bits/stdc++.h>
using namespace std;
#define fast                      \
    ios_base::sync_with_stdio(0); \
    cin.tie(NULL)
#define fr(i, a, b) for (ll i = a; i < b; i++)
#define fr1(i, n, a) for (ll i = n - 1; i >= a; i--)
#define vi vector<ll>
#define vvi vector<vector<ll>>
typedef long long ll;
#define pb push_back
#define mod 1000000007
#define sz(x) (long long)(x).size()
#define trace(x) cerr << #x << ": " << x << endl;
#define endl "\n";

//const ll mod= 998244353;
ll zero = 0;
ll modmulti(ll a, ll b)
{
    return ((a % mod) * 1ll * (b % mod)) % mod;
}
ll modadd(ll a, ll b)
{
    ll asdfgh = ((a % mod) + (b % mod) + mod + mod) % mod;
    asdfgh = (asdfgh + mod) % mod;
    return asdfgh;
}
ll modpower(ll a, ll n)
{
    if (n == 0)
        return 1;
    if (n == 1)
        return a % mod;
    ll b = modpower(a, n / 2);
    b = modmulti(b, b);
    if (n % 2 == 0)
        return b;
    return modmulti(a, b);
}
ll gcd(ll a, ll b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);
}
ll modinv(ll a)
{
    return modpower(a, mod - 2);
}
ll lcm(ll a, ll b)
{
    return (a * b) / gcd(a, b);
}

void err()
{
    cout << "-1\n";
    return;
}

template <typename ForwardIterator, typename T>
ForwardIterator first_less_than(ForwardIterator first, ForwardIterator last, T value)
{
    auto it = std::lower_bound(first, last, value);
    return (it == first ? last : --it);
}
const int N = 2 * 1e5 + 5;
//vector<ll> adj[N];
//ll level[N]={-1},parent[N],color[N];
struct vertex
{
    ll parent;
    ll rank;
    ll comp;
    vi vec;
};

typedef struct vertex vertex;

vertex ver[N];

ll find(ll n)
{
    ll x = n;
    while (x != ver[x].parent)
    {
        x = ver[x].parent;
    }
    ll y = n;
    ll z = ver[y].parent;
    while (y != z)
    {
        ver[y].parent = x;
        y = z;
        z = ver[z].parent;
    }
    return x;
}

void makeset(ll n)
{
    ver[n].rank = 0;
    ver[n].parent = n;
    ver[n].comp = 1;
    ver[n].vec.pb(n);
}

void initiate(ll n)
{
    fr(i, 0, n) makeset(i);
}

void join(vi &x, vi &y)
{
    x.insert(x.end(), y.begin(), y.end());
}

void uni(ll x, ll y)
{
    ll px = find(x);
    ll py = find(y);
    if (px == py)
        return;
    else if (ver[px].rank > ver[py].rank)
    {
        ver[py].parent = px;
        ver[px].comp += ver[py].comp;
        join(ver[px].vec, ver[py].vec);
    }
    else if (ver[py].rank > ver[px].rank)
    {
        ver[px].parent = py;
        ver[py].comp += ver[px].comp;
        join(ver[py].vec, ver[px].vec);
    }
    else
    {
        ver[py].parent = px;
        ver[px].rank++;
        ver[px].comp += ver[py].comp;
        join(ver[px].vec, ver[py].vec);
    }
}
set<ll> s;
void primeFactors(ll n)
{
    while (n % 2 == 0)
    {
        s.insert(2);
        n = n / 2;
    }
    for (ll i = 3; i <= sqrt(n); i = i + 2)
    {

        while (n % i == 0)
        {
            s.insert(i);
            n = n / i;
        }
    }
    if (n > 2)
        s.insert(n);
}

int main()
{
    ll t;ll sum=0;
    cin>>t;
    while(t-->0){
        int n;
        cin>>n;
        char vect[n+2];ll temp=0,max=0,ii=0,jj=0,minj=0,mini=0;
        int a[2*n+2][2*n+2]= {{0}};int currx=n+1;int curry=n+1;a[currx][curry]=1;
        string s;
        int size = sizeof(vect)/sizeof(vect[0]);
        cin>>vect;
        fr(i,0,n){
            if(vect[i]=='\0')
                break;

            if(vect[i]=='L')
                currx--;

            if(vect[i]=='R')
                currx++;
            if(vect[i]=='U')
                curry++;
            if(vect[i]=='D')
                curry--;
            if(a[currx][curry]!=0){
                ii=a[currx][curry];
                jj=i+2;
                if(jj-ii<max || max==0){
                    max=jj-ii;
                    minj=jj;
                    mini=ii;
                }

            }
             a[currx][curry]=i+2;

        }

        if(mini==0 and minj==0){
               cout<<-1<<endl;}
            else{
                 cout<<mini;
                 cout<<" ";
                 cout<<minj-1<<endl;
    }
    }

    return 0;
}

//cerr << "Time elapsed: " << clock() / (double)CLOCKS_PER_SEC << endl;
//return 0;


#include <bits/stdc++.h>
using namespace std;
#define fast                      \
    ios_base::sync_with_stdio(0); \
    cin.tie(NULL)
#define fr(i, a, b) for (ll i = a; i < b; i++)
#define fr1(i, n, a) for (ll i = n - 1; i >= a; i--)
#define vi vector<ll>
#define vvi vector<vector<ll>>
typedef long long ll;
#define pb push_back
#define mod 1000000007
#define sz(x) (long long)(x).size()
#define trace(x) cerr << #x << ": " << x << endl;
#define endl "\n";

//const ll mod= 998244353;
ll zero = 0;
ll modmulti(ll a, ll b)
{
    return ((a % mod) * 1ll * (b % mod)) % mod;
}
ll modadd(ll a, ll b)
{
    ll asdfgh = ((a % mod) + (b % mod) + mod + mod) % mod;
    asdfgh = (asdfgh + mod) % mod;
    return asdfgh;
}
ll modpower(ll a, ll n)
{
    if (n == 0)
        return 1;
    if (n == 1)
        return a % mod;
    ll b = modpower(a, n / 2);
    b = modmulti(b, b);
    if (n % 2 == 0)
        return b;
    return modmulti(a, b);
}
ll gcd(ll a, ll b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);
}
ll modinv(ll a)
{
    return modpower(a, mod - 2);
}
ll lcm(ll a, ll b)
{
    return (a * b) / gcd(a, b);
}

void err()
{
    cout << "-1\n";
    return;
}

template <typename ForwardIterator, typename T>
ForwardIterator first_less_than(ForwardIterator first, ForwardIterator last, T value)
{
    auto it = std::lower_bound(first, last, value);
    return (it == first ? last : --it);
}
const int N = 2 * 1e5 + 5;
//vector<ll> adj[N];
//ll level[N]={-1},parent[N],color[N];
struct vertex
{
    ll parent;
    ll rank;
    ll comp;
    vi vec;
};

typedef struct vertex vertex;

vertex ver[N];

ll find(ll n)
{
    ll x = n;
    while (x != ver[x].parent)
    {
        x = ver[x].parent;
    }
    ll y = n;
    ll z = ver[y].parent;
    while (y != z)
    {
        ver[y].parent = x;
        y = z;
        z = ver[z].parent;
    }
    return x;
}

void makeset(ll n)
{
    ver[n].rank = 0;
    ver[n].parent = n;
    ver[n].comp = 1;
    ver[n].vec.pb(n);
}

void initiate(ll n)
{
    fr(i, 0, n) makeset(i);
}

void join(vi &x, vi &y)
{
    x.insert(x.end(), y.begin(), y.end());
}

void uni(ll x, ll y)
{
    ll px = find(x);
    ll py = find(y);
    if (px == py)
        return;
    else if (ver[px].rank > ver[py].rank)
    {
        ver[py].parent = px;
        ver[px].comp += ver[py].comp;
        join(ver[px].vec, ver[py].vec);
    }
    else if (ver[py].rank > ver[px].rank)
    {
        ver[px].parent = py;
        ver[py].comp += ver[px].comp;
        join(ver[py].vec, ver[px].vec);
    }
    else
    {
        ver[py].parent = px;
        ver[px].rank++;
        ver[px].comp += ver[py].comp;
        join(ver[px].vec, ver[py].vec);
    }
}
set<ll> s;
void primeFactors(ll n)
{
    while (n % 2 == 0)
    {
        s.insert(2);
        n = n / 2;
    }
    for (ll i = 3; i <= sqrt(n); i = i + 2)
    {

        while (n % i == 0)
        {
            s.insert(i);
            n = n / i;
        }
    }
    if (n > 2)
        s.insert(n);
}

int main()
{
    ll t;ll sum=0;

    ios_base::sync_with_stdio(false);
        cin.tie(NULL);

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

        cin>>n;
        char vect[n+2];ll temp=0,max=0,ii=0,jj=0,minj=0,mini=0;
        int a[2*n+2][2*n+2]= {{0}};int currx=n+1;int curry=n+1;a[currx][curry]=1;
        string s;
        int size = sizeof(vect)/sizeof(vect[0]);
        scanf("%s",vect);
        fr(i,0,n){

            if(vect[i]=='L')
                currx--;

            if(vect[i]=='R')
                currx++;
            if(vect[i]=='U')
                curry++;
            if(vect[i]=='D')
                curry--;
            if(a[currx][curry]!=0){
                ii=a[currx][curry];
                jj=i+2;
                if(jj-ii<max || max==0){
                    max=jj-ii;
                    minj=jj;
                    mini=ii;
                }

            }
             a[currx][curry]=i+2;

        }

        if(mini==0 and minj==0){
               cout<<-1<<endl;}
            else{
                 cout<<mini;
                 cout<<" ";
                 cout<<minj-1<<endl;
    }
    }

    return 0;
}

//cerr << "Time elapsed: " << clock() / (double)CLOCKS_PER_SEC << endl;
//return 0;


#include <bits/stdc++.h>
using namespace std;
#define fast                      \
    ios_base::sync_with_stdio(0); \
    cin.tie(NULL)
#define fr(i, a, b) for (ll i = a; i < b; i++)
#define fr1(i, n, a) for (ll i = n - 1; i >= a; i--)
#define vi vector<ll>
#define vvi vector<vector<ll>>
typedef long long ll;
#define pb push_back
#define mod 1000000007
#define sz(x) (long long)(x).size()
#define trace(x) cerr << #x << ": " << x << endl;
#define endl "\n";

//const ll mod= 998244353;
ll zero = 0;
ll modmulti(ll a, ll b)
{
    return ((a % mod) * 1ll * (b % mod)) % mod;
}
ll modadd(ll a, ll b)
{
    ll asdfgh = ((a % mod) + (b % mod) + mod + mod) % mod;
    asdfgh = (asdfgh + mod) % mod;
    return asdfgh;
}
ll modpower(ll a, ll n)
{
    if (n == 0)
        return 1;
    if (n == 1)
        return a % mod;
    ll b = modpower(a, n / 2);
    b = modmulti(b, b);
    if (n % 2 == 0)
        return b;
    return modmulti(a, b);
}
ll gcd(ll a, ll b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);
}
ll modinv(ll a)
{
    return modpower(a, mod - 2);
}
ll lcm(ll a, ll b)
{
    return (a * b) / gcd(a, b);
}

void err()
{
    cout << "-1\n";
    return;
}

template <typename ForwardIterator, typename T>
ForwardIterator first_less_than(ForwardIterator first, ForwardIterator last, T value)
{
    auto it = std::lower_bound(first, last, value);
    return (it == first ? last : --it);
}
const int N = 2 * 1e5 + 5;
//vector<ll> adj[N];
//ll level[N]={-1},parent[N],color[N];
struct vertex
{
    ll parent;
    ll rank;
    ll comp;
    vi vec;
};

typedef struct vertex vertex;

vertex ver[N];

ll find(ll n)
{
    ll x = n;
    while (x != ver[x].parent)
    {
        x = ver[x].parent;
    }
    ll y = n;
    ll z = ver[y].parent;
    while (y != z)
    {
        ver[y].parent = x;
        y = z;
        z = ver[z].parent;
    }
    return x;
}

void makeset(ll n)
{
    ver[n].rank = 0;
    ver[n].parent = n;
    ver[n].comp = 1;
    ver[n].vec.pb(n);
}

void initiate(ll n)
{
    fr(i, 0, n) makeset(i);
}

void join(vi &x, vi &y)
{
    x.insert(x.end(), y.begin(), y.end());
}

void uni(ll x, ll y)
{
    ll px = find(x);
    ll py = find(y);
    if (px == py)
        return;
    else if (ver[px].rank > ver[py].rank)
    {
        ver[py].parent = px;
        ver[px].comp += ver[py].comp;
        join(ver[px].vec, ver[py].vec);
    }
    else if (ver[py].rank > ver[px].rank)
    {
        ver[px].parent = py;
        ver[py].comp += ver[px].comp;
        join(ver[py].vec, ver[px].vec);
    }
    else
    {
        ver[py].parent = px;
        ver[px].rank++;
        ver[px].comp += ver[py].comp;
        join(ver[px].vec, ver[py].vec);
    }
}
set<ll> s;
void primeFactors(ll n)
{
    while (n % 2 == 0)
    {
        s.insert(2);
        n = n / 2;
    }
    for (ll i = 3; i <= sqrt(n); i = i + 2)
    {

        while (n % i == 0)
        {
            s.insert(i);
            n = n / i;
        }
    }
    if (n > 2)
        s.insert(n);
}

int main()
{
    ll t;ll sum=0;
    cin>>t;
    while(t-->0){
        int n;
        ios_base::sync_with_stdio(false);
        cin.tie(NULL);
        cin>>n;
        char vect[n+2];ll temp=0,max=0,ii=0,jj=0,minj=0,mini=0;
        int a[2*n+2][2*n+2]= {{0}};int currx=n+1;int curry=n+1;a[currx][curry]=1;
        string s;
        int size = sizeof(vect)/sizeof(vect[0]);
        scanf("%s",vect);
        fr(i,0,n){
            if(vect[i]=='\0')
                break;

            if(vect[i]=='L')
                currx--;

            if(vect[i]=='R')
                currx++;
            if(vect[i]=='U')
                curry++;
            if(vect[i]=='D')
                curry--;
            if(a[currx][curry]!=0){
                ii=a[currx][curry];
                jj=i+2;
                if(jj-ii<max || max==0){
                    max=jj-ii;
                    minj=jj;
                    mini=ii;
                }

            }
             a[currx][curry]=i+2;

        }

        if(mini==0 and minj==0){
               cout<<-1<<endl;}
            else{
                 cout<<mini;
                 cout<<" ";
                 cout<<minj-1<<endl;
    }
    }

    return 0;
}

//cerr << "Time elapsed: " << clock() / (double)CLOCKS_PER_SEC << endl;
//return 0;


#include <bits/stdc++.h>
using namespace std;
#define fast                      \
    ios_base::sync_with_stdio(0); \
    cin.tie(NULL)
#define fr(i, a, b) for (ll i = a; i < b; i++)
#define fr1(i, n, a) for (ll i = n - 1; i >= a; i--)
#define vi vector<ll>
#define vvi vector<vector<ll>>
typedef long long ll;
#define pb push_back
#define mod 1000000007
#define sz(x) (long long)(x).size()
#define trace(x) cerr << #x << ": " << x << endl;
#define endl "\n";

//const ll mod= 998244353;
ll zero = 0;
ll modmulti(ll a, ll b)
{
    return ((a % mod) * 1ll * (b % mod)) % mod;
}
ll modadd(ll a, ll b)
{
    ll asdfgh = ((a % mod) + (b % mod) + mod + mod) % mod;
    asdfgh = (asdfgh + mod) % mod;
    return asdfgh;
}
ll modpower(ll a, ll n)
{
    if (n == 0)
        return 1;
    if (n == 1)
        return a % mod;
    ll b = modpower(a, n / 2);
    b = modmulti(b, b);
    if (n % 2 == 0)
        return b;
    return modmulti(a, b);
}
ll gcd(ll a, ll b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);
}
ll modinv(ll a)
{
    return modpower(a, mod - 2);
}
ll lcm(ll a, ll b)
{
    return (a * b) / gcd(a, b);
}

void err()
{
    cout << "-1\n";
    return;
}

template <typename ForwardIterator, typename T>
ForwardIterator first_less_than(ForwardIterator first, ForwardIterator last, T value)
{
    auto it = std::lower_bound(first, last, value);
    return (it == first ? last : --it);
}
const int N = 2 * 1e5 + 5;
//vector<ll> adj[N];
//ll level[N]={-1},parent[N],color[N];
struct vertex
{
    ll parent;
    ll rank;
    ll comp;
    vi vec;
};

typedef struct vertex vertex;

vertex ver[N];

ll find(ll n)
{
    ll x = n;
    while (x != ver[x].parent)
    {
        x = ver[x].parent;
    }
    ll y = n;
    ll z = ver[y].parent;
    while (y != z)
    {
        ver[y].parent = x;
        y = z;
        z = ver[z].parent;
    }
    return x;
}

void makeset(ll n)
{
    ver[n].rank = 0;
    ver[n].parent = n;
    ver[n].comp = 1;
    ver[n].vec.pb(n);
}

void initiate(ll n)
{
    fr(i, 0, n) makeset(i);
}

void join(vi &x, vi &y)
{
    x.insert(x.end(), y.begin(), y.end());
}

void uni(ll x, ll y)
{
    ll px = find(x);
    ll py = find(y);
    if (px == py)
        return;
    else if (ver[px].rank > ver[py].rank)
    {
        ver[py].parent = px;
        ver[px].comp += ver[py].comp;
        join(ver[px].vec, ver[py].vec);
    }
    else if (ver[py].rank > ver[px].rank)
    {
        ver[px].parent = py;
        ver[py].comp += ver[px].comp;
        join(ver[py].vec, ver[px].vec);
    }
    else
    {
        ver[py].parent = px;
        ver[px].rank++;
        ver[px].comp += ver[py].comp;
        join(ver[px].vec, ver[py].vec);
    }
}
set<ll> s;
void primeFactors(ll n)
{
    while (n % 2 == 0)
    {
        s.insert(2);
        n = n / 2;
    }
    for (ll i = 3; i <= sqrt(n); i = i + 2)
    {

        while (n % i == 0)
        {
            s.insert(i);
            n = n / i;
        }
    }
    if (n > 2)
        s.insert(n);
}

int main()
{
    ll t;ll sum=0;

    fast;

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

        cin>>n;
        char vect[n+2];ll temp=0,max=0,ii=0,jj=0,minj=0,mini=0;
        int a[2*n+2][2*n+2]= {{0}};int currx=n+1;int curry=n+1;a[currx][curry]=1;
        string s;
        int size = sizeof(vect)/sizeof(vect[0]);
        scanf("%s",vect);
        fr(i,0,n){

            if(vect[i]=='L')
                currx--;

            if(vect[i]=='R')
                currx++;
            if(vect[i]=='U')
                curry++;
            if(vect[i]=='D')
                curry--;
            if(a[currx][curry]!=0){
                ii=a[currx][curry];
                jj=i+2;
                if(jj-ii<max || max==0){
                    max=jj-ii;
                    minj=jj;
                    mini=ii;
                }

            }
             a[currx][curry]=i+2;

        }

        if(mini==0 and minj==0){
               cout<<-1<<endl;}
            else{
                 cout<<mini;
                 cout<<" ";
                 cout<<minj-1<<endl;
    }
    }

    return 0;
}

//cerr << "Time elapsed: " << clock() / (double)CLOCKS_PER_SEC << endl;
//return 0;


#include <bits/stdc++.h>
using namespace std;
#define fast                      \
    ios_base::sync_with_stdio(0); \
    cin.tie(NULL)
#define fr(i, a, b) for (ll i = a; i < b; i++)
#define fr1(i, n, a) for (ll i = n - 1; i >= a; i--)
#define vi vector<ll>
#define vvi vector<vector<ll>>
typedef long long ll;
#define pb push_back
#define mod 1000000007
#define sz(x) (long long)(x).size()
#define trace(x) cerr << #x << ": " << x << endl;
#define endl "\n";

//const ll mod= 998244353;
ll zero = 0;
ll modmulti(ll a, ll b)
{
    return ((a % mod) * 1ll * (b % mod)) % mod;
}
ll modadd(ll a, ll b)
{
    ll asdfgh = ((a % mod) + (b % mod) + mod + mod) % mod;
    asdfgh = (asdfgh + mod) % mod;
    return asdfgh;
}
ll modpower(ll a, ll n)
{
    if (n == 0)
        return 1;
    if (n == 1)
        return a % mod;
    ll b = modpower(a, n / 2);
    b = modmulti(b, b);
    if (n % 2 == 0)
        return b;
    return modmulti(a, b);
}
ll gcd(ll a, ll b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);
}
ll modinv(ll a)
{
    return modpower(a, mod - 2);
}
ll lcm(ll a, ll b)
{
    return (a * b) / gcd(a, b);
}

void err()
{
    cout << "-1\n";
    return;
}

template <typename ForwardIterator, typename T>
ForwardIterator first_less_than(ForwardIterator first, ForwardIterator last, T value)
{
    auto it = std::lower_bound(first, last, value);
    return (it == first ? last : --it);
}
const int N = 2 * 1e5 + 5;
//vector<ll> adj[N];
//ll level[N]={-1},parent[N],color[N];
struct vertex
{
    ll parent;
    ll rank;
    ll comp;
    vi vec;
};

typedef struct vertex vertex;

vertex ver[N];

ll find(ll n)
{
    ll x = n;
    while (x != ver[x].parent)
    {
        x = ver[x].parent;
    }
    ll y = n;
    ll z = ver[y].parent;
    while (y != z)
    {
        ver[y].parent = x;
        y = z;
        z = ver[z].parent;
    }
    return x;
}

void makeset(ll n)
{
    ver[n].rank = 0;
    ver[n].parent = n;
    ver[n].comp = 1;
    ver[n].vec.pb(n);
}

void initiate(ll n)
{
    fr(i, 0, n) makeset(i);
}

void join(vi &x, vi &y)
{
    x.insert(x.end(), y.begin(), y.end());
}

void uni(ll x, ll y)
{
    ll px = find(x);
    ll py = find(y);
    if (px == py)
        return;
    else if (ver[px].rank > ver[py].rank)
    {
        ver[py].parent = px;
        ver[px].comp += ver[py].comp;
        join(ver[px].vec, ver[py].vec);
    }
    else if (ver[py].rank > ver[px].rank)
    {
        ver[px].parent = py;
        ver[py].comp += ver[px].comp;
        join(ver[py].vec, ver[px].vec);
    }
    else
    {
        ver[py].parent = px;
        ver[px].rank++;
        ver[px].comp += ver[py].comp;
        join(ver[px].vec, ver[py].vec);
    }
}
set<ll> s;
void primeFactors(ll n)
{
    while (n % 2 == 0)
    {
        s.insert(2);
        n = n / 2;
    }
    for (ll i = 3; i <= sqrt(n); i = i + 2)
    {

        while (n % i == 0)
        {
            s.insert(i);
            n = n / i;
        }
    }
    if (n > 2)
        s.insert(n);
}

int main()
{
    ll t;ll sum=0;

    ios_base::sync_with_stdio(false);
        cin.tie(NULL);

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

        cin>>n;
        char vect[n+2];ll temp=0,max=0,ii=0,jj=0,minj=0,mini=0;
        int a[2*n+2][2*n+2]= {{0}};int currx=n+1;int curry=n+1;a[currx][curry]=1;
        string s;
        int size = sizeof(vect)/sizeof(vect[0]);
        scanf("%s",vect);
        fr(i,0,n){
            if(vect[i]=='\0')
                break;

            if(vect[i]=='L')
                currx--;

            if(vect[i]=='R')
                currx++;
            if(vect[i]=='U')
                curry++;
            if(vect[i]=='D')
                curry--;
            if(a[currx][curry]!=0){
                ii=a[currx][curry];
                jj=i+2;
                if(jj-ii<max || max==0){
                    max=jj-ii;
                    minj=jj;
                    mini=ii;
                }

            }
             a[currx][curry]=i+2;

        }

        if(mini==0 and minj==0){
               cout<<-1<<endl;}
            else{
                 cout<<mini;
                 cout<<" ";
                 cout<<minj-1<<endl;
    }
    }

    return 0;
}

//cerr << "Time elapsed: " << clock() / (double)CLOCKS_PER_SEC << endl;
//return 0;


#include <bits/stdc++.h>
using namespace std;
#define fast                      \
    ios_base::sync_with_stdio(0); \
    cin.tie(NULL)
#define fr(i, a, b) for (ll i = a; i < b; i++)
#define fr1(i, n, a) for (ll i = n - 1; i >= a; i--)
#define vi vector<ll>
#define vvi vector<vector<ll>>
typedef long long ll;
#define pb push_back
#define mod 1000000007
#define sz(x) (long long)(x).size()
#define trace(x) cerr << #x << ": " << x << endl;
#define endl "\n";

//const ll mod= 998244353;
ll zero = 0;
ll modmulti(ll a, ll b)
{
    return ((a % mod) * 1ll * (b % mod)) % mod;
}
ll modadd(ll a, ll b)
{
    ll asdfgh = ((a % mod) + (b % mod) + mod + mod) % mod;
    asdfgh = (asdfgh + mod) % mod;
    return asdfgh;
}
ll modpower(ll a, ll n)
{
    if (n == 0)
        return 1;
    if (n == 1)
        return a % mod;
    ll b = modpower(a, n / 2);
    b = modmulti(b, b);
    if (n % 2 == 0)
        return b;
    return modmulti(a, b);
}
ll gcd(ll a, ll b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);
}
ll modinv(ll a)
{
    return modpower(a, mod - 2);
}
ll lcm(ll a, ll b)
{
    return (a * b) / gcd(a, b);
}

void err()
{
    cout << "-1\n";
    return;
}

template <typename ForwardIterator, typename T>
ForwardIterator first_less_than(ForwardIterator first, ForwardIterator last, T value)
{
    auto it = std::lower_bound(first, last, value);
    return (it == first ? last : --it);
}
const int N = 2 * 1e5 + 5;
//vector<ll> adj[N];
//ll level[N]={-1},parent[N],color[N];
struct vertex
{
    ll parent;
    ll rank;
    ll comp;
    vi vec;
};

typedef struct vertex vertex;

vertex ver[N];

ll find(ll n)
{
    ll x = n;
    while (x != ver[x].parent)
    {
        x = ver[x].parent;
    }
    ll y = n;
    ll z = ver[y].parent;
    while (y != z)
    {
        ver[y].parent = x;
        y = z;
        z = ver[z].parent;
    }
    return x;
}

void makeset(ll n)
{
    ver[n].rank = 0;
    ver[n].parent = n;
    ver[n].comp = 1;
    ver[n].vec.pb(n);
}

void initiate(ll n)
{
    fr(i, 0, n) makeset(i);
}

void join(vi &x, vi &y)
{
    x.insert(x.end(), y.begin(), y.end());
}

void uni(ll x, ll y)
{
    ll px = find(x);
    ll py = find(y);
    if (px == py)
        return;
    else if (ver[px].rank > ver[py].rank)
    {
        ver[py].parent = px;
        ver[px].comp += ver[py].comp;
        join(ver[px].vec, ver[py].vec);
    }
    else if (ver[py].rank > ver[px].rank)
    {
        ver[px].parent = py;
        ver[py].comp += ver[px].comp;
        join(ver[py].vec, ver[px].vec);
    }
    else
    {
        ver[py].parent = px;
        ver[px].rank++;
        ver[px].comp += ver[py].comp;
        join(ver[px].vec, ver[py].vec);
    }
}
set<ll> s;
void primeFactors(ll n)
{
    while (n % 2 == 0)
    {
        s.insert(2);
        n = n / 2;
    }
    for (ll i = 3; i <= sqrt(n); i = i + 2)
    {

        while (n % i == 0)
        {
            s.insert(i);
            n = n / i;
        }
    }
    if (n > 2)
        s.insert(n);
}

int main()
{
    ll t;ll sum=0;

    fast;

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

        cin>>n;
        char vect[n+2];ll temp=0,max=0,ii=0,jj=0,minj=0,mini=0;
        int a[2*n+2][2*n+2]= {{0}};int currx=n+1;int curry=n+1;a[currx][curry]=1;
        string s;
        int size = sizeof(vect)/sizeof(vect[0]);
        cin>>vect;
        fr(i,0,n){

            if(vect[i]=='L')
                currx--;

            if(vect[i]=='R')
                currx++;
            if(vect[i]=='U')
                curry++;
            if(vect[i]=='D')
                curry--;
            if(a[currx][curry]!=0){
                ii=a[currx][curry];
                jj=i+2;
                if(jj-ii<max || max==0){
                    max=jj-ii;
                    minj=jj;
                    mini=ii;
                }

            }
             a[currx][curry]=i+2;

        }

        if(mini==0 and minj==0){
               cout<<-1<<endl;}
            else{
                 cout<<mini;
                 cout<<" ";
                 cout<<minj-1<<endl;
    }
    }

    return 0;
}

//cerr << "Time elapsed: " << clock() / (double)CLOCKS_PER_SEC << endl;
//return 0;


#include <bits/stdc++.h>
using namespace std;
#define fast                      \
    ios_base::sync_with_stdio(0); \
    cin.tie(NULL)
#define fr(i, a, b) for (ll i = a; i < b; i++)
#define fr1(i, n, a) for (ll i = n - 1; i >= a; i--)
#define vi vector<ll>
#define vvi vector<vector<ll>>
typedef long long ll;
#define pb push_back
#define mod 1000000007
#define sz(x) (long long)(x).size()
#define trace(x) cerr << #x << ": " << x << endl;
#define endl "\n";

//const ll mod= 998244353;
ll zero = 0;
ll modmulti(ll a, ll b)
{
    return ((a % mod) * 1ll * (b % mod)) % mod;
}
ll modadd(ll a, ll b)
{
    ll asdfgh = ((a % mod) + (b % mod) + mod + mod) % mod;
    asdfgh = (asdfgh + mod) % mod;
    return asdfgh;
}
ll modpower(ll a, ll n)
{
    if (n == 0)
        return 1;
    if (n == 1)
        return a % mod;
    ll b = modpower(a, n / 2);
    b = modmulti(b, b);
    if (n % 2 == 0)
        return b;
    return modmulti(a, b);
}
ll gcd(ll a, ll b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);
}
ll modinv(ll a)
{
    return modpower(a, mod - 2);
}
ll lcm(ll a, ll b)
{
    return (a * b) / gcd(a, b);
}

void err()
{
    cout << "-1\n";
    return;
}

template <typename ForwardIterator, typename T>
ForwardIterator first_less_than(ForwardIterator first, ForwardIterator last, T value)
{
    auto it = std::lower_bound(first, last, value);
    return (it == first ? last : --it);
}
const int N = 2 * 1e5 + 5;
//vector<ll> adj[N];
//ll level[N]={-1},parent[N],color[N];
struct vertex
{
    ll parent;
    ll rank;
    ll comp;
    vi vec;
};

typedef struct vertex vertex;

vertex ver[N];

ll find(ll n)
{
    ll x = n;
    while (x != ver[x].parent)
    {
        x = ver[x].parent;
    }
    ll y = n;
    ll z = ver[y].parent;
    while (y != z)
    {
        ver[y].parent = x;
        y = z;
        z = ver[z].parent;
    }
    return x;
}

void makeset(ll n)
{
    ver[n].rank = 0;
    ver[n].parent = n;
    ver[n].comp = 1;
    ver[n].vec.pb(n);
}

void initiate(ll n)
{
    fr(i, 0, n) makeset(i);
}

void join(vi &x, vi &y)
{
    x.insert(x.end(), y.begin(), y.end());
}

void uni(ll x, ll y)
{
    ll px = find(x);
    ll py = find(y);
    if (px == py)
        return;
    else if (ver[px].rank > ver[py].rank)
    {
        ver[py].parent = px;
        ver[px].comp += ver[py].comp;
        join(ver[px].vec, ver[py].vec);
    }
    else if (ver[py].rank > ver[px].rank)
    {
        ver[px].parent = py;
        ver[py].comp += ver[px].comp;
        join(ver[py].vec, ver[px].vec);
    }
    else
    {
        ver[py].parent = px;
        ver[px].rank++;
        ver[px].comp += ver[py].comp;
        join(ver[px].vec, ver[py].vec);
    }
}
set<ll> s;
void primeFactors(ll n)
{
    while (n % 2 == 0)
    {
        s.insert(2);
        n = n / 2;
    }
    for (ll i = 3; i <= sqrt(n); i = i + 2)
    {

        while (n % i == 0)
        {
            s.insert(i);
            n = n / i;
        }
    }
    if (n > 2)
        s.insert(n);
}

int main()
{
    ll t;ll sum=0;
    cin>>t;
    while(t-->0){
        int n;
        cin>>n;
        char vect[n+2];ll temp=0,max=0,ii=0,jj=0,minj=0,mini=0;
        int a[2*n+2][2*n+2]= {{0}};int currx=n+1;int curry=n+1;a[currx][curry]=1;
        string s;
        int size = sizeof(vect)/sizeof(vect[0]);
        scanf("%s",vect);
        fr(i,0,n){
            if(vect[i]=='\0')
                break;

            if(vect[i]=='L')
                currx--;

            if(vect[i]=='R')
                currx++;
            if(vect[i]=='U')
                curry++;
            if(vect[i]=='D')
                curry--;
            if(a[currx][curry]!=0){
                ii=a[currx][curry];
                jj=i+2;
                if(jj-ii<max || max==0){
                    max=jj-ii;
                    minj=jj;
                    mini=ii;
                }

            }
             a[currx][curry]=i+2;

        }

        if(mini==0 and minj==0){
               cout<<-1<<endl;}
            else{
                 cout<<mini;
                 cout<<" ";
                 cout<<minj-1<<endl;
    }
    }

    return 0;
}

//cerr << "Time elapsed: " << clock() / (double)CLOCKS_PER_SEC << endl;
//return 0;


#include <bits/stdc++.h>
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define GLHF ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL)
#define len(a) a.size()
#define f first
#define s second
#define eb emplace_back
#define pb push_back
#define ppb pop_back
#define pf push_front
#define ppf pop_front

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef long double ld;

const ll MOD = 1e9 + 7;
const int MAXN = 2.5e5;
const ll INF = LLONG_MAX;
const int N = 2e5 + 5;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

ll T1;
void timer()
{
    ll T2(clock());
    cout << "Exec time: " << (T2-T1) << "ms" << endl;
}

template<class A, class B> ostream& operator << (ostream& out, const pair<A, B>& a)
{
    out << "(" << a.f << ", " << a.s << ")";
}

template<class A> ostream& operator << (ostream& out, const vector<A>& a)
{
    out << "";
    for(auto it = a.begin(); it != a.end(); ++it)
    {
        if(it != a.begin()) out << " -> ";
        out << *it;
    }
    out << "";
}

template<class A> ostream& operator << (ostream& out, const set<A>& a)
{
    out << "{";
    for(auto it = a.begin(); it != a.end(); ++it)
    {
        if(it != a.begin()) out << ", ";
        out << *it;
    }
    out << "}";
}

template<class A, class B> ostream& operator << (ostream& out, const map<A, B>& a)
{
    out << "{" << endl;
    for(auto it = a.begin(); it != a.end(); ++it)
    {
        out << "   " << it->f << ": " << it->s;
        if(it != a.end()) out << ", ";
        out << endl;
    }
    out << "}";
}

template<class A> istream& operator >> (istream& in, vector<A>& a)
{
    for(auto &e : a)
        in >> e;
    return in;
}

template<class A, class B> istream& operator >> (istream& in, pair<A, B>& a)
{
    in >> a.f >> a.s;
    return in;
}

ll binpow(ll a, ll n)
{
   if(n == 0) return 1;
   if(n % 2) return binpow(a, n - 1) * a;
   else
   {
       ll b = binpow(a, n / 2);
       return b * b;
   }
}
ll binmult(ll a, ll n)
{
   if(n == 1) return 1;
   if(n % 2) return (binmult(a, n - 1) + a) % MOD;
   else
   {
       ll b = binmult(a, n / 2) % MOD;
       return (b + b) % MOD;
   }
}

//PLEASE DO NOT TOUCH THIS CODE
//CREATE A NEW PROJECT AND LIVE WITH CLEAR SOUL

//DO NOT TOUCH!!!!

int sz(int c1, int c2)
{
    return c2 - c1 + 1;
}

int main()
{
    GLHF;
    int t;
    cin >> t;
    while(t--)
    {
        int n;
        cin >> n;
        string s;
        cin >> s;
        map<pair<int, int>, set<int>> m;
        pair<int, int> c = {0, 0}, seg = {-1, -1};
        vector<pair<int, int> > pos;
        for(int i = 0; i < n; ++i)
        {
            if(!m[c].empty())
            {
                seg.f = *m[c].rbegin(), seg.s = i;
                pos.pb(seg);
                m[c].insert(i + 1);
            }
            else
                m[c].insert(i + 1);

            if(s[i] == 'L')
                c.f--;
            else if(s[i] == 'R')
                c.f++;
            else if(s[i] == 'U')
                c.s++;
            else
                c.s--;
        }
        cerr << m << endl;
        if(c == make_pair(0, 0)) pos.pb({1, n});
        if(pos.empty())
            cout << -1 << endl;
        else
        {
            int id = -1, mn = 1e9;
            for(int i = 0; i < len(pos); ++i)
            {
                if(sz(pos[i].f, pos[i].s) < mn)
                {
                    mn = sz(pos[i].f, pos[i].s);
                    id = i;
                }
            }
            cout << pos[id].f << ' ' << pos[id].s << endl;
        }
    }
    return 0;
}


#include <bits/stdc++.h>
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define GLHF ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL)
#define len(a) a.size()
#define f first
#define s second
#define eb emplace_back
#define pb push_back
#define ppb pop_back
#define pf push_front
#define ppf pop_front

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef long double ld;

const ll MOD = 1e9 + 7;
const int MAXN = 2.5e5;
const ll INF = LLONG_MAX;
const int N = 2e5 + 5;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

ll T1;
void timer()
{
    ll T2(clock());
    cout << "Exec time: " << (T2-T1) << "ms" << endl;
}

template<class A, class B> ostream& operator << (ostream& out, const pair<A, B>& a)
{
    out << "(" << a.f << ", " << a.s << ")";
}

template<class A> ostream& operator << (ostream& out, const vector<A>& a)
{
    out << "";
    for(auto it = a.begin(); it != a.end(); ++it)
    {
        if(it != a.begin()) out << " -> ";
        out << *it;
    }
    out << "";
}

template<class A> ostream& operator << (ostream& out, const set<A>& a)
{
    out << "{";
    for(auto it = a.begin(); it != a.end(); ++it)
    {
        if(it != a.begin()) out << ", ";
        out << *it;
    }
    out << "}";
}

template<class A, class B> ostream& operator << (ostream& out, const map<A, B>& a)
{
    out << "{" << endl;
    for(auto it = a.begin(); it != a.end(); ++it)
    {
        out << "   " << it->f << ": " << it->s;
        if(it != a.end()) out << ", ";
        out << endl;
    }
    out << "}";
}

template<class A> istream& operator >> (istream& in, vector<A>& a)
{
    for(auto &e : a)
        in >> e;
    return in;
}

template<class A, class B> istream& operator >> (istream& in, pair<A, B>& a)
{
    in >> a.f >> a.s;
    return in;
}

ll binpow(ll a, ll n)
{
   if(n == 0) return 1;
   if(n % 2) return binpow(a, n - 1) * a;
   else
   {
       ll b = binpow(a, n / 2);
       return b * b;
   }
}
ll binmult(ll a, ll n)
{
   if(n == 1) return 1;
   if(n % 2) return (binmult(a, n - 1) + a) % MOD;
   else
   {
       ll b = binmult(a, n / 2) % MOD;
       return (b + b) % MOD;
   }
}

//PLEASE DO NOT TOUCH THIS CODE
//CREATE A NEW PROJECT AND LIVE WITH CLEAR SOUL

//DO NOT TOUCH!!!!

int sz(int c1, int c2)
{
    return c2 - c1 + 1;
}

int main()
{
    GLHF;
    int t;
    cin >> t;
    while(t--)
    {
        int n;
        cin >> n;
        string s;
        cin >> s;
        map<pair<int, int>, vector<int>> m;
        pair<int, int> c = {0, 0}, seg = {-1, -1};
        vector<pair<int, int> > pos;
        for(int i = 0; i < n; ++i)
        {
            if(!m[c].empty())
            {
                m[c].pb(i + 1);
                seg.f = m[c][len(m[c]) - 2] + 1, seg.s = m[c].back();
                pos.pb(seg);
            }
            else
                m[c].pb(i + 1);
            if(s[i] == 'L')
                c.f--;
            else if(s[i] == 'R')
                c.f++;
            else if(s[i] == 'U')
                c.s++;
            else
                c.s--;

        }
        cerr << m << endl;
        if(c == make_pair(0, 0)) pos.pb({1, n});
        if(pos.empty())
            cout << -1 << endl;
        else
        {
            int id = -1, mn = 1e9;
            for(int i = 0; i < len(pos); ++i)
            {
                if(sz(pos[i].f, pos[i].s) < mn)
                {
                    mn = sz(pos[i].f, pos[i].s);
                    id = i;
                }
            }
            cout << pos[id].f << ' ' << pos[id].s << endl;
        }
    }
    return 0;
}


#include <bits/stdc++.h>
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define GLHF ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL)
#define len(a) a.size()
#define f first
#define s second
#define eb emplace_back
#define pb push_back
#define ppb pop_back
#define pf push_front
#define ppf pop_front

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef long double ld;

const ll MOD = 1e9 + 7;
const int MAXN = 2.5e5;
const ll INF = LLONG_MAX;
const int N = 2e5 + 5;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

ll T1;
void timer()
{
    ll T2(clock());
    cout << "Exec time: " << (T2-T1) << "ms" << endl;
}

template<class A, class B> ostream& operator << (ostream& out, const pair<A, B>& a)
{
    out << "(" << a.f << ", " << a.s << ")";
}

template<class A> ostream& operator << (ostream& out, const vector<A>& a)
{
    out << "";
    for(auto it = a.begin(); it != a.end(); ++it)
    {
        if(it != a.begin()) out << " -> ";
        out << *it;
    }
    out << "";
}

template<class A> ostream& operator << (ostream& out, const set<A>& a)
{
    out << "{";
    for(auto it = a.begin(); it != a.end(); ++it)
    {
        if(it != a.begin()) out << ", ";
        out << *it;
    }
    out << "}";
}

template<class A, class B> ostream& operator << (ostream& out, const map<A, B>& a)
{
    out << "{" << endl;
    for(auto it = a.begin(); it != a.end(); ++it)
    {
        out << "   " << it->f << ": " << it->s;
        if(it != a.end()) out << ", ";
        out << endl;
    }
    out << "}";
}

template<class A> istream& operator >> (istream& in, vector<A>& a)
{
    for(auto &e : a)
        in >> e;
    return in;
}

template<class A, class B> istream& operator >> (istream& in, pair<A, B>& a)
{
    in >> a.f >> a.s;
    return in;
}

ll binpow(ll a, ll n)
{
   if(n == 0) return 1;
   if(n % 2) return binpow(a, n - 1) * a;
   else
   {
       ll b = binpow(a, n / 2);
       return b * b;
   }
}
ll binmult(ll a, ll n)
{
   if(n == 1) return 1;
   if(n % 2) return (binmult(a, n - 1) + a) % MOD;
   else
   {
       ll b = binmult(a, n / 2) % MOD;
       return (b + b) % MOD;
   }
}

//PLEASE DO NOT TOUCH THIS CODE
//CREATE A NEW PROJECT AND LIVE WITH CLEAR SOUL

//DO NOT TOUCH!!!!

int sz(int c1, int c2)
{
    return c2 - c1 + 1;
}

int main()
{
    GLHF;
    int t;
    cin >> t;
    while(t--)
    {
        int n;
        cin >> n;
        string s;
        cin >> s;
        map<pair<int, int>, set<int>> m;
        pair<int, int> c = {0, 0}, seg = {-1, -1};
        vector<pair<int, int> > pos;
        for(int i = 0; i < n; ++i)
        {
            if(!m[c].empty())
            {
                seg.f = *m[c].rbegin() + 1, seg.s = i + 1;
                pos.pb(seg);
                m[c].insert(i + 1);
            }
            else
                m[c].insert(i + 1);

            if(s[i] == 'L')
                c.f--;
            else if(s[i] == 'R')
                c.f++;
            else if(s[i] == 'U')
                c.s++;
            else
                c.s--;
        }
        // cerr << m << endl;
        if(c == make_pair(0, 0)) pos.pb({1, n});
        if(pos.empty())
            cout << -1 << endl;
        else
        {
            int id = -1, mn = 1e9;
            for(int i = 0; i < len(pos); ++i)
            {
                if(sz(pos[i].f, pos[i].s) < mn)
                {
                    mn = sz(pos[i].f, pos[i].s);
                    id = i;
                }
            }
            cout << pos[id].f << ' ' << pos[id].s << endl;
        }
    }
    return 0;
}


#include <bits/stdc++.h>
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define GLHF ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL)
#define len(a) a.size()
#define f first
#define s second
#define eb emplace_back
#define pb push_back
#define ppb pop_back
#define pf push_front
#define ppf pop_front

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef long double ld;

const ll MOD = 1e9 + 7;
const int MAXN = 2.5e5;
const ll INF = LLONG_MAX;
const int N = 2e5 + 5;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

ll T1;
void timer()
{
    ll T2(clock());
    cout << "Exec time: " << (T2-T1) << "ms" << endl;
}

template<class A, class B> ostream& operator << (ostream& out, const pair<A, B>& a)
{
    out << "(" << a.f << ", " << a.s << ")";
}

template<class A> ostream& operator << (ostream& out, const vector<A>& a)
{
    out << "";
    for(auto it = a.begin(); it != a.end(); ++it)
    {
        if(it != a.begin()) out << " -> ";
        out << *it;
    }
    out << "";
}

template<class A> ostream& operator << (ostream& out, const set<A>& a)
{
    out << "{";
    for(auto it = a.begin(); it != a.end(); ++it)
    {
        if(it != a.begin()) out << ", ";
        out << *it;
    }
    out << "}";
}

template<class A, class B> ostream& operator << (ostream& out, const map<A, B>& a)
{
    out << "{" << endl;
    for(auto it = a.begin(); it != a.end(); ++it)
    {
        out << "   " << it->f << ": " << it->s;
        if(it != a.end()) out << ", ";
        out << endl;
    }
    out << "}";
}

template<class A> istream& operator >> (istream& in, vector<A>& a)
{
    for(auto &e : a)
        in >> e;
    return in;
}

template<class A, class B> istream& operator >> (istream& in, pair<A, B>& a)
{
    in >> a.f >> a.s;
    return in;
}

ll binpow(ll a, ll n)
{
   if(n == 0) return 1;
   if(n % 2) return binpow(a, n - 1) * a;
   else
   {
       ll b = binpow(a, n / 2);
       return b * b;
   }
}
ll binmult(ll a, ll n)
{
   if(n == 1) return 1;
   if(n % 2) return (binmult(a, n - 1) + a) % MOD;
   else
   {
       ll b = binmult(a, n / 2) % MOD;
       return (b + b) % MOD;
   }
}

//PLEASE DO NOT TOUCH THIS CODE
//CREATE A NEW PROJECT AND LIVE WITH CLEAR SOUL

//DO NOT TOUCH!!!!

int sz(int c1, int c2)
{
    return c2 - c1 + 1;
}

int main()
{
    GLHF;
    int t;
    cin >> t;
    while(t--)
    {
        int n;
        cin >> n;
        string s;
        cin >> s;
        map<pair<int, int>, vector<int>> m;
        pair<int, int> c = {0, 0}, seg = {-1, -1};
        vector<pair<int, int> > pos;
        for(int i = 0; i < n; ++i)
        {
            if(!m[c].empty())
            {
                m[c].pb(i + 1);
                seg.f = m[c][len(m[c]) - 2] + 1, seg.s = m[c].back();
                pos.pb(seg);
            }
            else
                m[c].pb(i + 1);
            if(s[i] == 'L')
                c.f--;
            else if(s[i] == 'R')
                c.f++;
            else if(s[i] == 'U')
                c.s++;
            else
                c.s--;

        }
        //cerr << m << endl;
        if(c == make_pair(0, 0)) pos.pb({1, n});
        if(pos.empty())
            cout << -1 << endl;
        else
        {
            int id = -1, mn = 1e9;
            for(int i = 0; i < len(pos); ++i)
            {
                if(sz(pos[i].f, pos[i].s) < mn)
                {
                    mn = sz(pos[i].f, pos[i].s);
                    id = i;
                }
            }
            cout << pos[id].f << ' ' << pos[id].s << endl;
        }
    }
    return 0;
}


#include <bits/stdc++.h>
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define GLHF ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL)
#define len(a) a.size()
#define f first
#define s second
#define eb emplace_back
#define pb push_back
#define ppb pop_back
#define pf push_front
#define ppf pop_front

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef long double ld;

const ll MOD = 1e9 + 7;
const int MAXN = 2.5e5;
const ll INF = LLONG_MAX;
const int N = 2e5 + 5;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

ll T1;
void timer()
{
    ll T2(clock());
    cout << "Exec time: " << (T2-T1) << "ms" << endl;
}

template<class A, class B> ostream& operator << (ostream& out, const pair<A, B>& a)
{
    out << "(" << a.x << ", " << a.y << ")";
}

template<class A> ostream& operator << (ostream& out, const vector<A>& a)
{
    out << "";
    for(auto it = a.begin(); it != a.end(); ++it)
    {
        if(it != a.begin()) out << " -> ";
        out << *it;
    }
    out << "";
}

template<class A> ostream& operator << (ostream& out, const set<A>& a)
{
    out << "{";
    for(auto it = a.begin(); it != a.end(); ++it)
    {
        if(it != a.begin()) out << ", ";
        out << *it;
    }
    out << "}";
}

template<class A, class B> ostream& operator << (ostream& out, const map<A, B>& a)
{
    out << "{" << endl;
    for(auto it = a.begin(); it != a.end(); ++it)
    {
        out << "   " << it->f << ": " << it->s;
        if(it != a.end()) out << ", ";
        out << endl;
    }
    out << "}";
}

template<class A> istream& operator >> (istream& in, vector<A>& a)
{
    for(auto &e : a)
        in >> e;
    return in;
}

template<class A, class B> istream& operator >> (istream& in, pair<A, B>& a)
{
    in >> a.f >> a.s;
    return in;
}

ll binpow(ll a, ll n)
{
   if(n == 0) return 1;
   if(n % 2) return binpow(a, n - 1) * a;
   else
   {
       ll b = binpow(a, n / 2);
       return b * b;
   }
}
ll binmult(ll a, ll n)
{
   if(n == 1) return 1;
   if(n % 2) return (binmult(a, n - 1) + a) % MOD;
   else
   {
       ll b = binmult(a, n / 2) % MOD;
       return (b + b) % MOD;
   }
}

//PLEASE DO NOT TOUCH THIS CODE
//CREATE A NEW PROJECT AND LIVE WITH CLEAR SOUL

//DO NOT TOUCH!!!!

int main()
{
    GLHF;
    int t;
    cin >> t;
    while(t--)
    {
        int n;
        cin >> n;
        string s;
        cin >> s;
        map<pair<int, int>, int> m;
        pair<int, int> c = {0, 0}, ans = {-1, -1};
        for(int i = 0; i < n; ++i)
        {
            if(s[i] == 'L')
                c.f--;
            else if(s[i] == 'R')
                c.f++;
            else if(s[i] == 'U')
                c.s++;
            else
                c.s--;

            if(!m[c])
                m[c] = i + 1;
            else
            {
                ans.f = m[c] + 1, ans.s = i + 1;
                break;
            }
        }
        if(c == make_pair(0, 0) && ans.f == -1) ans.f = 1, ans.s = n;
        if(ans.f != -1)
            cout << ans.f << ' ' << ans.s << endl;
        else
            cout << ans.f << endl;
    }
    return 0;
}


#include <bits/stdc++.h>
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define GLHF ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL)
#define len(a) a.size()
#define f first
#define s second
#define eb emplace_back
#define pb push_back
#define ppb pop_back
#define pf push_front
#define ppf pop_front

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef long double ld;

const ll MOD = 1e9 + 7;
const int MAXN = 2.5e5;
const ll INF = LLONG_MAX;
const int N = 2e5 + 5;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

ll T1;
void timer()
{
    ll T2(clock());
    cout << "Exec time: " << (T2-T1) << "ms" << endl;
}

template<class A, class B> ostream& operator << (ostream& out, const pair<A, B>& a)
{
    out << "(" << a.f << ", " << a.s << ")";
}

template<class A> ostream& operator << (ostream& out, const vector<A>& a)
{
    out << "";
    for(auto it = a.begin(); it != a.end(); ++it)
    {
        if(it != a.begin()) out << " -> ";
        out << *it;
    }
    out << "";
}

template<class A> ostream& operator << (ostream& out, const set<A>& a)
{
    out << "{";
    for(auto it = a.begin(); it != a.end(); ++it)
    {
        if(it != a.begin()) out << ", ";
        out << *it;
    }
    out << "}";
}

template<class A, class B> ostream& operator << (ostream& out, const map<A, B>& a)
{
    out << "{" << endl;
    for(auto it = a.begin(); it != a.end(); ++it)
    {
        out << "   " << it->f << ": " << it->s;
        if(it != a.end()) out << ", ";
        out << endl;
    }
    out << "}";
}

template<class A> istream& operator >> (istream& in, vector<A>& a)
{
    for(auto &e : a)
        in >> e;
    return in;
}

template<class A, class B> istream& operator >> (istream& in, pair<A, B>& a)
{
    in >> a.f >> a.s;
    return in;
}

ll binpow(ll a, ll n)
{
   if(n == 0) return 1;
   if(n % 2) return binpow(a, n - 1) * a;
   else
   {
       ll b = binpow(a, n / 2);
       return b * b;
   }
}
ll binmult(ll a, ll n)
{
   if(n == 1) return 1;
   if(n % 2) return (binmult(a, n - 1) + a) % MOD;
   else
   {
       ll b = binmult(a, n / 2) % MOD;
       return (b + b) % MOD;
   }
}

//PLEASE DO NOT TOUCH THIS CODE
//CREATE A NEW PROJECT AND LIVE WITH CLEAR SOUL

//DO NOT TOUCH!!!!

int sz(int c1, int c2)
{
    return c2 - c1 + 1;
}

int main()
{
    GLHF;
    int t;
    cin >> t;
    while(t--)
    {
        int n;
        cin >> n;
        string s;
        cin >> s;
        map<pair<int, int>, int> m;
        pair<int, int> c = {0, 0}, seg = {-1, -1};
        vector<pair<int, int> > pos;
        for(int i = 0; i < n; ++i)
        {
            if(m[c])
            {
                seg.f = m[c], seg.s = i;
                pos.pb(seg);
                m[c] = i + 1;
            }
            else
                m[c] = i + 1;

            if(s[i] == 'L')
                c.f--;
            else if(s[i] == 'R')
                c.f++;
            else if(s[i] == 'U')
                c.s++;
            else
                c.s--;
        }
        cerr << m << endl;
        if(c == make_pair(0, 0)) pos.pb({1, n});
        if(pos.empty())
            cout << -1 << endl;
        else
        {
            int id = -1, mn = 1e9;
            for(int i = 0; i < len(pos); ++i)
            {
                if(sz(pos[i].f, pos[i].s) < mn)
                {
                    mn = sz(pos[i].f, pos[i].s);
                    id = i;
                }
            }
            cout << pos[id].f << ' ' << pos[id].s << endl;
        }
    }
    return 0;
}


#include <bits/stdc++.h>
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define GLHF ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL)
#define len(a) a.size()
#define f first
#define s second
#define eb emplace_back
#define pb push_back
#define ppb pop_back
#define pf push_front
#define ppf pop_front

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef long double ld;

const ll MOD = 1e9 + 7;
const int MAXN = 2.5e5;
const ll INF = LLONG_MAX;
const int N = 2e5 + 5;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

ll T1;
void timer()
{
    ll T2(clock());
    cout << "Exec time: " << (T2-T1) << "ms" << endl;
}

template<class A, class B> ostream& operator << (ostream& out, const pair<A, B>& a)
{
    out << "(" << a.f << ", " << a.s << ")";
}

template<class A> ostream& operator << (ostream& out, const vector<A>& a)
{
    out << "";
    for(auto it = a.begin(); it != a.end(); ++it)
    {
        if(it != a.begin()) out << " -> ";
        out << *it;
    }
    out << "";
}

template<class A> ostream& operator << (ostream& out, const set<A>& a)
{
    out << "{";
    for(auto it = a.begin(); it != a.end(); ++it)
    {
        if(it != a.begin()) out << ", ";
        out << *it;
    }
    out << "}";
}

template<class A, class B> ostream& operator << (ostream& out, const map<A, B>& a)
{
    out << "{" << endl;
    for(auto it = a.begin(); it != a.end(); ++it)
    {
        out << "   " << it->f << ": " << it->s;
        if(it != a.end()) out << ", ";
        out << endl;
    }
    out << "}";
}

template<class A> istream& operator >> (istream& in, vector<A>& a)
{
    for(auto &e : a)
        in >> e;
    return in;
}

template<class A, class B> istream& operator >> (istream& in, pair<A, B>& a)
{
    in >> a.f >> a.s;
    return in;
}

ll binpow(ll a, ll n)
{
   if(n == 0) return 1;
   if(n % 2) return binpow(a, n - 1) * a;
   else
   {
       ll b = binpow(a, n / 2);
       return b * b;
   }
}
ll binmult(ll a, ll n)
{
   if(n == 1) return 1;
   if(n % 2) return (binmult(a, n - 1) + a) % MOD;
   else
   {
       ll b = binmult(a, n / 2) % MOD;
       return (b + b) % MOD;
   }
}

//PLEASE DO NOT TOUCH THIS CODE
//CREATE A NEW PROJECT AND LIVE WITH CLEAR SOUL

//DO NOT TOUCH!!!!

int sz(int c1, int c2)
{
    return c2 - c1 + 1;
}

int main()
{
    GLHF;
    int t;
    cin >> t;
    while(t--)
    {
        int n;
        cin >> n;
        string s;
        cin >> s;
        map<pair<int, int>, int> is, was;
        pair<int, int> c = {0, 0}, seg = {-1, -1};
        int l = 1e9;
        is[c] = 0;
        was[c] = 1;
        for(int i = 0; i < n; ++i)
        {
            if(s[i] == 'L') c.f--;
            else if(s[i] == 'R') c.f++;
            else if(s[i] == 'U') c.s++;
            else c.s--;
            if(was[c])
            {
                if(i - is[c] < l)
                {
                    l = i - is[c];
                    seg.f = is[c] + 1;
                    seg.s = i + 1;
                }
            }
            was[c] = 1;
            is[c] = i + 1;
        }
        if(l == 1e9)
            cout << -1 << endl;
        else
            cout << seg.f << ' ' << seg.s << endl;
    }
    return 0;
}


#include <bits/stdc++.h>
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define GLHF ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL)
#define len(a) a.size()
#define f first
#define s second
#define eb emplace_back
#define pb push_back
#define ppb pop_back
#define pf push_front
#define ppf pop_front

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef long double ld;

const ll MOD = 1e9 + 7;
const int MAXN = 2.5e5;
const ll INF = LLONG_MAX;
const int N = 2e5 + 5;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

ll T1;
void timer()
{
    ll T2(clock());
    cout << "Exec time: " << (T2-T1) << "ms" << endl;
}

template<class A, class B> ostream& operator << (ostream& out, const pair<A, B>& a)
{
    out << "(" << a.f << ", " << a.s << ")";
}

template<class A> ostream& operator << (ostream& out, const vector<A>& a)
{
    out << "";
    for(auto it = a.begin(); it != a.end(); ++it)
    {
        if(it != a.begin()) out << " -> ";
        out << *it;
    }
    out << "";
}

template<class A> ostream& operator << (ostream& out, const set<A>& a)
{
    out << "{";
    for(auto it = a.begin(); it != a.end(); ++it)
    {
        if(it != a.begin()) out << ", ";
        out << *it;
    }
    out << "}";
}

template<class A, class B> ostream& operator << (ostream& out, const map<A, B>& a)
{
    out << "{" << endl;
    for(auto it = a.begin(); it != a.end(); ++it)
    {
        out << "   " << it->f << ": " << it->s;
        if(it != a.end()) out << ", ";
        out << endl;
    }
    out << "}";
}

template<class A> istream& operator >> (istream& in, vector<A>& a)
{
    for(auto &e : a)
        in >> e;
    return in;
}

template<class A, class B> istream& operator >> (istream& in, pair<A, B>& a)
{
    in >> a.f >> a.s;
    return in;
}

ll binpow(ll a, ll n)
{
   if(n == 0) return 1;
   if(n % 2) return binpow(a, n - 1) * a;
   else
   {
       ll b = binpow(a, n / 2);
       return b * b;
   }
}
ll binmult(ll a, ll n)
{
   if(n == 1) return 1;
   if(n % 2) return (binmult(a, n - 1) + a) % MOD;
   else
   {
       ll b = binmult(a, n / 2) % MOD;
       return (b + b) % MOD;
   }
}

//PLEASE DO NOT TOUCH THIS CODE
//CREATE A NEW PROJECT AND LIVE WITH CLEAR SOUL

//DO NOT TOUCH!!!!

int sz(int c1, int c2)
{
    return c2 - c1 + 1;
}

int main()
{
    GLHF;
    int t;
    cin >> t;
    while(t--)
    {
        int n;
        cin >> n;
        string s;
        cin >> s;
        map<pair<int, int>, set<int>> m;
        pair<int, int> c = {0, 0}, seg = {-1, -1};
        vector<pair<int, int> > pos;
        for(int i = 0; i < n; ++i)
        {
            if(!m[c].empty())
            {
                seg.f = *m[c].rbegin(), seg.s = i;
                pos.pb(seg);
                m[c].insert(i + 1);
            }
            else
                m[c].insert(i + 1);

            if(s[i] == 'L')
                c.f--;
            else if(s[i] == 'R')
                c.f++;
            else if(s[i] == 'U')
                c.s++;
            else
                c.s--;
        }
        //cerr << m << endl;
        if(c == make_pair(0, 0)) pos.pb({1, n});
        if(pos.empty())
            cout << -1 << endl;
        else
        {
            int id = -1, mn = 1e9;
            for(int i = 0; i < len(pos); ++i)
            {
                if(sz(pos[i].f, pos[i].s) < mn)
                {
                    mn = sz(pos[i].f, pos[i].s);
                    id = i;
                }
            }
            cout << pos[id].f << ' ' << pos[id].s << endl;
        }
    }
    return 0;
}


#include <bits/stdc++.h>
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define GLHF ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL)
#define len(a) a.size()
#define f first
#define s second
#define eb emplace_back
#define pb push_back
#define ppb pop_back
#define pf push_front
#define ppf pop_front

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef long double ld;

const ll MOD = 1e9 + 7;
const int MAXN = 2.5e5;
const ll INF = LLONG_MAX;
const int N = 2e5 + 5;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

ll T1;
void timer()
{
    ll T2(clock());
    cout << "Exec time: " << (T2-T1) << "ms" << endl;
}

template<class A, class B> ostream& operator << (ostream& out, const pair<A, B>& a)
{
    out << "(" << a.x << ", " << a.y << ")";
}

template<class A> ostream& operator << (ostream& out, const vector<A>& a)
{
    out << "";
    for(auto it = a.begin(); it != a.end(); ++it)
    {
        if(it != a.begin()) out << " -> ";
        out << *it;
    }
    out << "";
}

template<class A> ostream& operator << (ostream& out, const set<A>& a)
{
    out << "{";
    for(auto it = a.begin(); it != a.end(); ++it)
    {
        if(it != a.begin()) out << ", ";
        out << *it;
    }
    out << "}";
}

template<class A, class B> ostream& operator << (ostream& out, const map<A, B>& a)
{
    out << "{" << endl;
    for(auto it = a.begin(); it != a.end(); ++it)
    {
        out << "   " << it->f << ": " << it->s;
        if(it != a.end()) out << ", ";
        out << endl;
    }
    out << "}";
}

template<class A> istream& operator >> (istream& in, vector<A>& a)
{
    for(auto &e : a)
        in >> e;
    return in;
}

template<class A, class B> istream& operator >> (istream& in, pair<A, B>& a)
{
    in >> a.f >> a.s;
    return in;
}

ll binpow(ll a, ll n)
{
   if(n == 0) return 1;
   if(n % 2) return binpow(a, n - 1) * a;
   else
   {
       ll b = binpow(a, n / 2);
       return b * b;
   }
}
ll binmult(ll a, ll n)
{
   if(n == 1) return 1;
   if(n % 2) return (binmult(a, n - 1) + a) % MOD;
   else
   {
       ll b = binmult(a, n / 2) % MOD;
       return (b + b) % MOD;
   }
}

//PLEASE DO NOT TOUCH THIS CODE
//CREATE A NEW PROJECT AND LIVE WITH CLEAR SOUL

//DO NOT TOUCH!!!!

int sz(int c1, int c2)
{
    return c2 - c1 + 1;
}

int main()
{
    GLHF;
    int t;
    cin >> t;
    while(t--)
    {
        int n;
        cin >> n;
        string s;
        cin >> s;
        map<pair<int, int>, int> m;
        pair<int, int> c = {0, 0}, seg = {-1, -1};
        vector<pair<int, int> > pos;
        for(int i = 0; i < n; ++i)
        {
            if(m[c])
            {
                seg.f = m[c], seg.s = i;
                pos.pb(seg);
            }
            else
                m[c] = i + 1;

            if(s[i] == 'L')
                c.f--;
            else if(s[i] == 'R')
                c.f++;
            else if(s[i] == 'U')
                c.s++;
            else
                c.s--;
        }
        if(c == make_pair(0, 0)) pos.pb({1, n});
        if(pos.empty())
            cout << -1 << endl;
        else
        {
            int id = -1, mn = 1e9;
            for(int i = 0; i < len(pos); ++i)
            {
                if(sz(pos[i].f, pos[i].s) < mn)
                {
                    mn = sz(pos[i].f, pos[i].s);
                    id = i;
                }
            }
            cout << pos[id].f << ' ' << pos[id].s << endl;
        }
    }
    return 0;
}


#include <bits/stdc++.h>
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define GLHF ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL)
#define len(a) a.size()
#define f first
#define s second
#define eb emplace_back
#define pb push_back
#define ppb pop_back
#define pf push_front
#define ppf pop_front

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef long double ld;

const ll MOD = 1e9 + 7;
const int MAXN = 2.5e5;
const ll INF = LLONG_MAX;
const int N = 2e5 + 5;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

ll T1;
void timer()
{
    ll T2(clock());
    cout << "Exec time: " << (T2-T1) << "ms" << endl;
}

template<class A, class B> ostream& operator << (ostream& out, const pair<A, B>& a)
{
    out << "(" << a.x << ", " << a.y << ")";
}

template<class A> ostream& operator << (ostream& out, const vector<A>& a)
{
    out << "";
    for(auto it = a.begin(); it != a.end(); ++it)
    {
        if(it != a.begin()) out << " -> ";
        out << *it;
    }
    out << "";
}

template<class A> ostream& operator << (ostream& out, const set<A>& a)
{
    out << "{";
    for(auto it = a.begin(); it != a.end(); ++it)
    {
        if(it != a.begin()) out << ", ";
        out << *it;
    }
    out << "}";
}

template<class A, class B> ostream& operator << (ostream& out, const map<A, B>& a)
{
    out << "{" << endl;
    for(auto it = a.begin(); it != a.end(); ++it)
    {
        out << "   " << it->f << ": " << it->s;
        if(it != a.end()) out << ", ";
        out << endl;
    }
    out << "}";
}

template<class A> istream& operator >> (istream& in, vector<A>& a)
{
    for(auto &e : a)
        in >> e;
    return in;
}

template<class A, class B> istream& operator >> (istream& in, pair<A, B>& a)
{
    in >> a.f >> a.s;
    return in;
}

ll binpow(ll a, ll n)
{
   if(n == 0) return 1;
   if(n % 2) return binpow(a, n - 1) * a;
   else
   {
       ll b = binpow(a, n / 2);
       return b * b;
   }
}
ll binmult(ll a, ll n)
{
   if(n == 1) return 1;
   if(n % 2) return (binmult(a, n - 1) + a) % MOD;
   else
   {
       ll b = binmult(a, n / 2) % MOD;
       return (b + b) % MOD;
   }
}

//PLEASE DO NOT TOUCH THIS CODE
//CREATE A NEW PROJECT AND LIVE WITH CLEAR SOUL

//DO NOT TOUCH!!!!

int main()
{
    GLHF;
    int t;
    cin >> t;
    while(t--)
    {
        int n;
        cin >> n;
        string s;
        cin >> s;
        map<pair<int, int>, int> m;
        pair<int, int> c = {0, 0}, ans = {-1, -1};
        for(int i = 0; i < n; ++i)
        {
            if(m[c])
            {
                ans.f = m[c], ans.s = i;
                break;
            }
            else
                m[c] = i + 1;

            if(s[i] == 'L')
                c.f--;
            else if(s[i] == 'R')
                c.f++;
            else if(s[i] == 'U')
                c.s++;
            else
                c.s--;

        }
        if(c == make_pair(0, 0) && ans.f == -1) ans.f = 1, ans.s = n;
        if(ans.f != -1)
            cout << ans.f << ' ' << ans.s << endl;
        else
            cout << ans.f << endl;
    }
    return 0;
}


#include <bits/stdc++.h>
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define GLHF ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL)
#define len(a) a.size()
#define f first
#define s second
#define eb emplace_back
#define pb push_back
#define ppb pop_back
#define pf push_front
#define ppf pop_front

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef long double ld;

const ll MOD = 1e9 + 7;
const int MAXN = 2.5e5;
const ll INF = LLONG_MAX;
const int N = 2e5 + 5;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

ll T1;
void timer()
{
    ll T2(clock());
    cout << "Exec time: " << (T2-T1) << "ms" << endl;
}

template<class A, class B> ostream& operator << (ostream& out, const pair<A, B>& a)
{
    out << "(" << a.f << ", " << a.s << ")";
}

template<class A> ostream& operator << (ostream& out, const vector<A>& a)
{
    out << "";
    for(auto it = a.begin(); it != a.end(); ++it)
    {
        if(it != a.begin()) out << " -> ";
        out << *it;
    }
    out << "";
}

template<class A> ostream& operator << (ostream& out, const set<A>& a)
{
    out << "{";
    for(auto it = a.begin(); it != a.end(); ++it)
    {
        if(it != a.begin()) out << ", ";
        out << *it;
    }
    out << "}";
}

template<class A, class B> ostream& operator << (ostream& out, const map<A, B>& a)
{
    out << "{" << endl;
    for(auto it = a.begin(); it != a.end(); ++it)
    {
        out << "   " << it->f << ": " << it->s;
        if(it != a.end()) out << ", ";
        out << endl;
    }
    out << "}";
}

template<class A> istream& operator >> (istream& in, vector<A>& a)
{
    for(auto &e : a)
        in >> e;
    return in;
}

template<class A, class B> istream& operator >> (istream& in, pair<A, B>& a)
{
    in >> a.f >> a.s;
    return in;
}

ll binpow(ll a, ll n)
{
   if(n == 0) return 1;
   if(n % 2) return binpow(a, n - 1) * a;
   else
   {
       ll b = binpow(a, n / 2);
       return b * b;
   }
}
ll binmult(ll a, ll n)
{
   if(n == 1) return 1;
   if(n % 2) return (binmult(a, n - 1) + a) % MOD;
   else
   {
       ll b = binmult(a, n / 2) % MOD;
       return (b + b) % MOD;
   }
}

//PLEASE DO NOT TOUCH THIS CODE
//CREATE A NEW PROJECT AND LIVE WITH CLEAR SOUL

//DO NOT TOUCH!!!!

int sz(int c1, int c2)
{
    return c2 - c1 + 1;
}

int main()
{
    GLHF;
    int t;
    cin >> t;
    while(t--)
    {
        int n;
        cin >> n;
        string s;
        cin >> s;
        map<pair<int, int>, int> m;
        pair<int, int> c = {0, 0}, seg = {-1, -1};
        vector<pair<int, int> > pos;
        for(int i = 0; i < n; ++i)
        {
            if(m[c])
            {
                seg.f = m[c], seg.s = i;
                pos.pb(seg);
                m[c] = i + 1;
            }
            else
                m[c] = i + 1;

            if(s[i] == 'L')
                c.f--;
            else if(s[i] == 'R')
                c.f++;
            else if(s[i] == 'U')
                c.s++;
            else
                c.s--;
        }
        //cerr << m << endl;
        if(c == make_pair(0, 0)) pos.pb({1, n});
        if(pos.empty())
            cout << -1 << endl;
        else
        {
            int id = -1, mn = 1e9;
            for(int i = 0; i < len(pos); ++i)
            {
                if(sz(pos[i].f, pos[i].s) < mn)
                {
                    mn = sz(pos[i].f, pos[i].s);
                    id = i;
                }
            }
            cout << pos[id].f << ' ' << pos[id].s << endl;
        }
    }
    return 0;
}


#include <bits/stdc++.h>
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define GLHF ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL)
#define len(a) a.size()
#define f first
#define s second
#define eb emplace_back
#define pb push_back
#define ppb pop_back
#define pf push_front
#define ppf pop_front

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef long double ld;

const ll MOD = 1e9 + 7;
const int MAXN = 2.5e5;
const ll INF = LLONG_MAX;
const int N = 2e5 + 5;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

ll T1;
void timer()
{
    ll T2(clock());
    cout << "Exec time: " << (T2-T1) << "ms" << endl;
}

template<class A, class B> ostream& operator << (ostream& out, const pair<A, B>& a)
{
    out << "(" << a.x << ", " << a.y << ")";
}

template<class A> ostream& operator << (ostream& out, const vector<A>& a)
{
    out << "";
    for(auto it = a.begin(); it != a.end(); ++it)
    {
        if(it != a.begin()) out << " -> ";
        out << *it;
    }
    out << "";
}

template<class A> ostream& operator << (ostream& out, const set<A>& a)
{
    out << "{";
    for(auto it = a.begin(); it != a.end(); ++it)
    {
        if(it != a.begin()) out << ", ";
        out << *it;
    }
    out << "}";
}

template<class A, class B> ostream& operator << (ostream& out, const map<A, B>& a)
{
    out << "{" << endl;
    for(auto it = a.begin(); it != a.end(); ++it)
    {
        out << "   " << it->f << ": " << it->s;
        if(it != a.end()) out << ", ";
        out << endl;
    }
    out << "}";
}

template<class A> istream& operator >> (istream& in, vector<A>& a)
{
    for(auto &e : a)
        in >> e;
    return in;
}

template<class A, class B> istream& operator >> (istream& in, pair<A, B>& a)
{
    in >> a.f >> a.s;
    return in;
}

ll binpow(ll a, ll n)
{
   if(n == 0) return 1;
   if(n % 2) return binpow(a, n - 1) * a;
   else
   {
       ll b = binpow(a, n / 2);
       return b * b;
   }
}
ll binmult(ll a, ll n)
{
   if(n == 1) return 1;
   if(n % 2) return (binmult(a, n - 1) + a) % MOD;
   else
   {
       ll b = binmult(a, n / 2) % MOD;
       return (b + b) % MOD;
   }
}

//PLEASE DO NOT TOUCH THIS CODE
//CREATE A NEW PROJECT AND LIVE WITH CLEAR SOUL

//DO NOT TOUCH!!!!

int sz(int c1, int c2)
{
    return c2 - c1 + 1;
}

int main()
{
    GLHF;
    int t;
    cin >> t;
    while(t--)
    {
        int n;
        cin >> n;
        string s;
        cin >> s;
        map<pair<int, int>, int> m;
        pair<int, int> c = {0, 0}, ans = {-1, -1};
        for(int i = 0; i < n; ++i)
        {
            if(m[c])
            {
                if(sz(ans.f, ans.s) > sz(i, m[c]))
                    ans.f = m[c], ans.s = i;
            }
            else
                m[c] = i + 1;

            if(s[i] == 'L')
                c.f--;
            else if(s[i] == 'R')
                c.f++;
            else if(s[i] == 'U')
                c.s++;
            else
                c.s--;
        }
        if(c == make_pair(0, 0) && ans.f == -1) ans.f = 1, ans.s = n;
        if(ans.f != -1)
            cout << ans.f << ' ' << ans.s << endl;
        else
            cout << ans.f << endl;
    }
    return 0;
}