#include<iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <string>
#include <cmath>
#include <stack>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <functional>
#include <ctime>
#include <iomanip>
#include <sstream>
#include <algorithm>
#define ll long long
#define PI acos(-1)
#define mes(x,y) memset(x,y,sizeof(x))
#define lp pair<ll, ll>
#define FAST_IO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
using namespace std;
ll GCD(ll a, ll b) {//最大公约数
	return b == 0 ? a : GCD(b, a % b);
}
ll Power(ll a, ll b, ll p) { //计算(a^b)%p;
	ll ans = 1;
	while (b) {
		if (b & 1) //等价于b%2，判断b的奇偶性
			ans = ans * a % p; //如果为奇数，证明该位为1，需要乘上a
		a = a * a % p; //计算a^(2^i)
		b >>= 1; //等价于b/=2;
	}
	return ans;
}
bool isPrime(ll num)
{
	if (num == 2 || num == 3)
		return true;
	if (num % 6 != 1 && num % 6 != 5)
		return false;
	ll t = sqrt((double)num);
	for (ll i = 5; i <= t; i += 6)
		if (num % i == 0 || num % (i + 2) == 0)
			return false;
	return true;
}
bool isRunyear(int year)
{
	if (year % 4 == 0 && year % 100 != 0 || year % 400 == 0)
	{
		return true;
	}
	else {
		return false;
	}
}
string add(string s1, string s2)
{
	if (s1.length() < s2.length())
	{
		string temp = s1;
		s1 = s2;
		s2 = temp;
	}
	int i, j;
	for (i = s1.length() - 1, j = s2.length() - 1; i >= 0; i--, j--)
	{
		s1[i] = char(s1[i] + (j >= 0 ? s2[j] - '0' : 0));   //注意细节
		if (s1[i] - '0' >= 10)
		{
			s1[i] = char((s1[i] - '0') % 10 + '0');
			if (i) s1[i - 1]++;
			else s1 = '1' + s1;
		}
	}
	return s1;
}
inline int read() {
	int x = 0, f = 1;
	char ch = getchar();
	while (ch < '0' || ch > '9') {
		if (ch == '-')
			f = -1;
		ch = getchar();
	}
	while (ch >= '0' && ch <= '9') {
		x = (x << 1) + (x << 3) + (ch ^ 48);
		ch = getchar();
	}
	return x * f;
}
ll n, m, i, j, k, t, flag, x, y, z;
const ll INF = 5e6 + 30;
string s, s1, s2;
ll a[200300];
int main() {
	FAST_IO;
	while (cin >> t) {
		while (t--) {
			cin >> n;
			for (i = 0; i < n; i++)cin >> a[i];
			i = n - 1;
			while (i >= 0 && a[i] <= a[i - 1])i--;
			while (i >= 0 && a[i] >= a[i - 1])i--;
			cout << (i == -1 ? 0 : i) << endl;
		}
	}
}


#include <iostream>
#include <vector>
#include <stack>
#include <map>
#include <algorithm>
#include <string>
#include <cmath>
#include <set>
#include <unordered_set>
#include <fstream>
#include <unordered_map>
#include <queue>
#include <iomanip>
#include <clocale>
//#include <Windows.h>

using namespace std;

typedef long long int ll;
typedef long double ld;

map<char, int> digits = {
	{'0', 0},
	{'1', 1},
	{'2', 2},
	{'3', 3},
	{'4', 4},
	{'5', 5},
	{'6', 6},
	{'7', 7},
	{'8', 8},
	{'9', 9}
};

map<int, char> positions = {
	{0, 'a'},
	{1, 'b'},
	{2, 'c'},
	{3, 'd'},
	{4, 'e'},
	{5, 'f'},
	{6, 'g'},
	{7, 'h'}
};

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

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

		vector<ll> arr(n);

		for (int i = 0; i < n; i++) {
			cin >> arr[i];
		}

		if (n == 2) {
			cout << 0 << endl;
			return 0;
		}

		ll last = (ll)n - 1;
		bool stop = false;
		for (ll i = last; i >= 1 && !stop; i--) {
			if (arr[i] <= arr[i - 1]) {
				last = i - 1;
			}
			else stop = true;
		}

		ll first = last;
		stop = false;

		for (ll i = last; i >= 1 && !stop; i--) {
			if (arr[i] >= arr[i - 1]) {
				first = i - 1;
			}
			else stop = true;
		}

		cout << first << endl;

		/*

		bool stop = false;
		int last_index_of_decreasing_seq = n - 1;
		for (int i = n - 1; i >= 1 && !stop; i--) {
			if (arr[i - 1] < arr[i]) {
				stop = true;
			}
			last_index_of_decreasing_seq = i;
		}

		stop = false;
		int start_of_increasing_seq = 0;

		for (int i = last_index_of_decreasing_seq; i >= 1 && !stop; i--) {
			if (arr[i - 1] > arr[i]) {
				stop = true;
			}
			start_of_increasing_seq = i;
		}

		cout << start_of_increasing_seq << endl;
		*/

	}

	return 0;
}

/*

1
3
1 2 3

1
2
13 12

1
14
4 7 7 3 4 4 4 8 7 6 5 4 3 2

1
5
5 4 3 2 3

1
3
4 5 2

*/


#include <iostream>
#include <vector>
#include <stack>
#include <map>
#include <algorithm>
#include <string>
#include <cmath>
#include <set>
#include <unordered_set>
#include <fstream>
#include <unordered_map>
#include <queue>
#include <iomanip>
#include <clocale>
//#include <Windows.h>

using namespace std;

typedef long long int ll;
typedef long double ld;

map<char, int> digits = {
	{'0', 0},
	{'1', 1},
	{'2', 2},
	{'3', 3},
	{'4', 4},
	{'5', 5},
	{'6', 6},
	{'7', 7},
	{'8', 8},
	{'9', 9}
};

map<int, char> positions = {
	{0, 'a'},
	{1, 'b'},
	{2, 'c'},
	{3, 'd'},
	{4, 'e'},
	{5, 'f'},
	{6, 'g'},
	{7, 'h'}
};

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

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

		vector<ll> arr(n);

		for (int i = 0; i < n; i++) {
			cin >> arr[i];
		}

		bool stop = false;
		int last_index_of_decreasing_seq = n - 1;
		for (int i = n - 1; i >= 1 && !stop; i--) {
			if (arr[i] > arr[i - 1]) {
				stop = true;
				last_index_of_decreasing_seq = i;
			}
		}

		stop = false;
		int start_of_increasing_seq = 0;

		for (int i = last_index_of_decreasing_seq; i >= 1 && !stop; i--) {
			if (arr[i - 1] > arr[i]) {
				start_of_increasing_seq = i;
				stop = true;
			}
		}

		cout << start_of_increasing_seq << endl;

	}

	return 0;
}

/*

1
5
5 4 3 2 3

1
3
4 5 2

*/


#include <iostream>
#include <vector>
#include <stack>
#include <map>
#include <algorithm>
#include <string>
#include <cmath>
#include <set>
#include <unordered_set>
#include <fstream>
#include <unordered_map>
#include <queue>
#include <iomanip>
#include <clocale>
//#include <Windows.h>

using namespace std;

typedef long long int ll;
typedef long double ld;

map<char, int> digits = {
	{'0', 0},
	{'1', 1},
	{'2', 2},
	{'3', 3},
	{'4', 4},
	{'5', 5},
	{'6', 6},
	{'7', 7},
	{'8', 8},
	{'9', 9}
};

map<int, char> positions = {
	{0, 'a'},
	{1, 'b'},
	{2, 'c'},
	{3, 'd'},
	{4, 'e'},
	{5, 'f'},
	{6, 'g'},
	{7, 'h'}
};

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

	while (t--) {
		int n; cin >> n;
		vector<ll> arr(n);

		for (int i = 0; i < n; i++) {
			ll elem; cin >> elem;
			arr[i] = elem;
		}

		bool swap = false, stop = false;
		int index = arr.size() - 1;
		for (int i = arr.size() - 2; i >= 0 && !stop; i--) {
			if (!swap) {
				if (arr[i] < arr[i + 1]) {
					swap = true;
				}

				index = i;
			}

			else {
				if (arr[i] > arr[i + 1]) {
					stop = true;
				}
				else index = i;
			}
		}

		cout << index << endl;

	}

	return 0;
}

/*

1
7
4 3 3 8 4 5 2

*/


#include <iostream>
#include <vector>
#include <stack>
#include <map>
#include <algorithm>
#include <string>
#include <cmath>
#include <set>
#include <unordered_set>
#include <fstream>
#include <unordered_map>
#include <queue>
#include <iomanip>
#include <clocale>
//#include <Windows.h>

using namespace std;

typedef long long int ll;
typedef long double ld;

map<char, int> digits = {
	{'0', 0},
	{'1', 1},
	{'2', 2},
	{'3', 3},
	{'4', 4},
	{'5', 5},
	{'6', 6},
	{'7', 7},
	{'8', 8},
	{'9', 9}
};

map<int, char> positions = {
	{0, 'a'},
	{1, 'b'},
	{2, 'c'},
	{3, 'd'},
	{4, 'e'},
	{5, 'f'},
	{6, 'g'},
	{7, 'h'}
};

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

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

		vector<ll> arr(n);

		for (int i = 0; i < n; i++) {
			cin >> arr[i];
		}

		bool stop = false;
		int last_index_of_decreasing_seq = n - 1;
		for (int i = n - 1; i >= 1 && !stop; i--) {
			if (arr[i] > arr[i - 1]) {
				stop = true;
				last_index_of_decreasing_seq = i;
			}
		}

		int start_of_increasing_seq = 0;

		for (int i = 0; i < last_index_of_decreasing_seq; i++) {
			if (arr[i] > arr[i + 1]) {
				start_of_increasing_seq = i + 1;
			}
		}

		//cout << start_of_increasing_seq << " " << last_index_of_decreasing_seq << endl;

		int len = n - start_of_increasing_seq;
		cout << n - len << endl;

	}

	return 0;
}

/*

1
5
5 4 3 2 3

1
3
4 5 2

*/


#include<iostream>
#include<vector>
#include<cmath>
#include<iomanip>
#include<algorithm>
#include<map>
#include<stack>
#include<string>
#include<set>
using namespace std;
int num[55];
int main() {
	int t;
	cin >> t;
	while (t--) {
		int n;
		cin >> n;
		int pp = 0, p = 0;
		int last = 0;
		for (int i = 1;i <= n;i++) {
			int a;
			cin >> a;
			if (last > a) {

				p = i - 1;
				//cout << "last > a:" << p << endl;
			}
			else if(last<a){
				pp = p;
			}
			last = a;
		}
		cout << pp << endl;
	}
}


#include<iostream>
#include<vector>
#include<cmath>
#include<iomanip>
#include<algorithm>
#include<map>
#include<stack>
#include<string>
#include<set>
using namespace std;
int num[55];
int main() {
	int t;
	cin >> t;
	while (t--) {
		int n;
		cin >> n;
		int pp=0, p=0;
		int last = 0;
		for (int i = 1;i <= n;i++) {
			int a;
			cin >> a;
			if (last > a) {
				p = i-1;
			}
			else {
				pp = p;
			}
			last = a;
		}
		cout << pp << endl;
	}
}


#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<algorithm>
#include<set>
#include<cstdio>
#include<queue>
#include<string>
#include<cstdio>
#include<map>
#include<sstream>
#include<string.h>
#include<vector>
using namespace std;
struct w {
	int x;
	long long y;
}bi[100005];
bool cmpa(w a, w b)
{
	return a.y > b.y;
}
int ai[200005];
int main()
{
	int t;
	cin >> t;
	while (t--)
	{
		memset(ai, 0, sizeof(ai));
		int m;
		cin >> m;
		for (int i = 1; i <= m; i++)
		{
			cin >> ai[i];
		}
		while (ai[m - 1] >= ai[m]&&m>1)
		{
			ai[m] = 0;
			m--;
		}
		while (ai[m - 1] <= ai[m] && m > 1)
		{
			ai[m] = 0;
			m--;
		}
		int i;
		for (i = 1; ai[i] != 0; i++);
		cout << i - 2;
		cout << endl;
	}
	return 0;
}


#include<iostream>
#include<cstdlib>
#include<map>
#include<cmath>
#include<vector>
#include<stack>
#include<cstring>
#include<queue>
#include<algorithm>
#define N 200005
#define mod 5
#define inf 50000
using namespace std;
int a[N];
int main()
{
	int i,j,k,n,t,m,p;
	int tail,n1;
	scanf("%d",&n);
	while(n--){
		scanf("%d",&m);
		for(i=0;i<m;i++){
			scanf("%d",&a[i]);
		}
		j=k=0;
		t=i-1;
		while(t>0&&a[t]<=a[t-1]){
			t--;
		}
		while(t>0&&a[t]>=a[t-1]){
			t--;
		}
		if(t<0){
			t=0;
		}
		printf("%d\n",t);
	}
	return 0;
}


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

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

	while (t--)
	{
		int n;
		cin >> n;
		vector<int> l;
		int x;

		for (int i = 0; i < n; i++)
		{
			cin >> x;
			l.push_back(x);
		}
		int s = 0;
		for (int i = 0; i < n - 1; i++)
		{
			if (i < n - 1 && l[i] > l[i + 1])
			{
				int k = i + 1;
				while (k < n - 1 && l[k] > l[k + 1])
				{
					k++;
				}

				if (k < n - 1)
				{
					s = i + 1;
				}
			}

		}

		cout << s << endl;
	}

	return 0;
}


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

int main()
{
	long long t;
	cin >> t;

	while (t--)
	{
		long long n;
		cin >> n;
		vector<long long> l;
		long long x;

		for (long long i = 0; i < n; i++)
		{
			cin >> x;
			l.push_back(x);
		}
		long long s = 0;
		for (long long i = 0; i < n - 1; i++)
		{
			if (i < n - 1 && l[i] > l[i + 1])
			{
				long long k = i + 1;
				while (k < n - 1 && l[k] > l[k + 1])
				{
					k++;
				}

				if (k < n - 1)
				{
					s = i + 1;
				}
			}

		}

		cout << s << endl;
	}

	return 0;
}


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

int main()
{
	int t;

	cin >> t;

	while (t--)
	{
		int n, x;
		int start = 0;
		cin >> n;
		vector<int> a;

		for (int i = 0; i < n; i++)
		{
			cin >> x;
			a.push_back(x);
		}

		int i = n - 1;

		while (i > 0 && a[i] <= a[i - 1])
		{
			i--;
		}

		while (i > 0 && a[i] >= a[i - 1])
		{
			i--;
		}

		cout << i << endl;

	}
	return 0;
}


#include <iostream>
#include <algorithm>
#include <map>
#include <string>
#include <random>
using namespace std;

void solve() {
    int n;
    cin >> n;

    vector<int> v(n);
    for (int &x : v)
        cin >> x;

    int p = n - 1;
    while (0 <= p - 1 && v[p - 1] >= v[p])
        p--;
    while (0 <= p - 1 && v[p - 1] <= v[p])
        p--;
    cout << p << "\n";
}

int main() {
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

    int n;
    cin >> n;

    for (int i = 0; i < n; i++)
        solve();
}


#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#include <queue>
#include <map>
#include <utility>
#include <iterator>
#include <deque>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

#define pii pair <int, int>
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define fi first
#define se second

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

    int t;
    cin >> t;
    while (t--) {
        int n;
        cin >> n;
        vector <int> a(n);
        for (auto & i : a) cin >> i;
        int i = n - 1;
        while (i > 0 && a[i - 1] >= a[i]) i--;
        while (i > 0 && a[i - 1] <= a[i]) i--;
        cout << max(0, i) << '\n';
    }

    return 0;
}

/*
        ▄▀▀▀▀▄
        █  ▀ █▄▄
   ▄ ▄▄▄▀▄ █▀▀▀
   █▀▄  ▀▄  ▀▄
   █  ▀▀▀    █
    ▀▄▄▄▄▄▄▄▀
*/


#define _CRT_SECURE_NO_WARNINGS

#include <algorithm>
#include <cstdio>
#include <vector>

using namespace std;

int main() {
    int tests;
    scanf("%d", &tests);
    vector<int> a;
    a.resize(100002);
    for (int test = 0; test < tests; ++test) {
        int n;
        scanf("%d", &n);
        for (int i = 0; i < n; ++i) {
            scanf("%d", &a[i]);

        }
        int state = 0 ,answer = 0;
        for (int i = n-1; i >= 0; --i) {
            if (state == 0) {
                if (a[i] >= a[i + 1]) {
                    continue;
                }
            }
            if (state == 1) {
                if (a[i] <= a[i + 1]) {
                    continue;
                }
            }
            state++;
            if (state == 2) {
                answer = i + 1;
                break;
            }
        }
        printf("%d\n", answer);
    }
    return 0;
}


#define _CRT_SECURE_NO_WARNINGS

#include <algorithm>
#include <cstdio>
#include <vector>

using namespace std;

int main() {
    int tests;
    scanf("%d", &tests);
    vector<int> a;
    a.resize(200002);
    for (int test = 0; test < tests; ++test) {
        int n;
        scanf("%d", &n);
        for (int i = 0; i < n; ++i) {
            scanf("%d", &a[i]);

        }
        int state = 0 ,answer = 0;
        for (int i = n-1; i >= 0; --i) {
            if (state == 0) {
                if (a[i] >= a[i + 1]) {
                    continue;
                }
            }
            if (state == 1) {
                if (a[i] <= a[i + 1]) {
                    continue;
                }
            }
            state++;
            if (state == 2) {
                answer = i + 1;
                break;
            }
        }
        printf("%d\n", answer);
    }
    return 0;
}


#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <cmath>
#include <string>

using namespace std;

int main() {
    int t;
    cin >> t;
    for (int jk = 0; jk < t; jk++) {
        int n;
        cin >> n;
        vector<int> a(n);
        vector<pair<int, int>>b;
        for (int i = 0; i < n; i++) {
            cin >> a[i];
            b.push_back(make_pair(a[i], i));
        }
        sort(b.begin(), b.end());
        int ans = 0;
        int l = 0, r = n - 1, j = 0;
        vector<bool> used(n);
        while (r - l > 0) {
            while (j < n && used[b[j].second]) {
                j++;
            }
            while (l < r && a[l] != b[j].first && a[r] != b[j].first) {
                used[l] = 1;
                l++;
                ans = l;
            }
            if (l < r && a[r] == b[j].first) {
                used[r] = 1;
                r--;
            }
            if (l < r && a[l] == b[j].first) {
                used[l] = 1;
                l++;
            }
        }
        cout << ans << "\n";
    }
    return 0;
}

/*
5 100
1 2 3 4 5
GET 1 3 4 5
Get 1 5 1 5
Get 1 5 3 4
Set 2 3
Get 1 5 3 3
Get 1 5 3 3
*/


#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <cmath>
#include <string>

using namespace std;

int main() {
    int t;
    cin >> t;
    for (int jk = 0; jk < t; jk++) {
        int n;
        cin >> n;
        vector<int> a(n);
        vector<pair<int, int>>b;
        for (int i = 0; i < n; i++) {
            cin >> a[i];
            b.push_back({ a[i], i });
        }
        sort(b.begin(), b.end());
        int ans = 0;
        int l = 0, r = n - 1, j = 0;
        vector<bool> used(n);
        while (r - l > 0) {
            while (j < n && used[b[j].second]) {
                j++;
            }
            while (l < r && a[l] != b[j].first && a[r] != b[j].first) {
                used[l] = 1;
                l++;
                ans = l;
            }
            if (l < r && a[r] == b[j].first) {
                used[r] = 1;
                r--;
            }
            if (l < r && a[l] == b[j].first) {
                used[l] = 1;
                l++;
            }
        }
        cout << ans << "\n";
    }
    return 0;
}

/*
5 100
1 2 3 4 5
GET 1 3 4 5
Get 1 5 1 5
Get 1 5 3 4
Set 2 3
Get 1 5 3 3
Get 1 5 3 3
*/


#include <iostream>
#include <cmath>
using namespace std;
int main()
{
    int t,n,k=1,fl=0;
    int a[200000];
    cin>>t;
    for(int i=0;i<t;i++)
    {
        cin>>n;
        for(int j=0;j<n;j++)
        {
            cin>>a[j];
        }
        for(int j=n-2;j>=0;j--)
        {
            if(fl==0)
            {
                if(a[j]>=a[j+1])
                {
                    k++;
                    continue;
                }
                else
                {
                    k++;
                    fl++;
                    continue;
                }
            }
            else
            {
                if(a[j]<=a[j+1])
                {
                    k++;
                    continue;
                }
                else
                {
                    break;
                }
            }
        }
        cout<<n-k<<endl;
        k=1;
        fl=0;
    }
}


#include <iostream>
#include <cstdio>

using namespace std;

int a[200000 + 10];

int main()
{

	int t;
	cin >> t;

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

		for(int i = 0;i < n;i++)
			cin >> a[n -  1 - i];

		int ok  = 1;
		int ans = 1;

		for(int i = 1;i < n;i++)
		{
			if(ok)
			{
				if(a[i] < a[i - 1])
					ok = 0;
				ans++;
			}
			else
			{
				if(a[i] > a[i - 1]) break;
				ans++;
			}
		}
		cout << n - ans << endl;
	}

	return 0;
}


#include<iostream>
#include<vector>
using namespace std;
int main()
{
    int t;
    cin>>t;
    while(t--)
    {
        int n;
        cin>>n;
        vector<int>v;
        for(int i=0;i<n;i++)
        {
            int a;
            cin>>a;
            v.push_back(a);
        }
        int i;
        for(i=n-1;i>0;i--)
        {
            if(a[i-1]>a[i])
                continue;
            else
                break;
        }
        int j;
        for( j=i;j>0;j--)
        {
            if(a[j]>a[j-1])
                continue;
            else
                break;
        }
        cout<<j<<endl;
    }
}


#include<iostream>
#include<vector>
using namespace std;
int main()
{
    int t;
    cin>>t;
    while(t--)
    {
        int n;
        cin>>n;
        vector<int>v;
        for(int i=0;i<n;i++)
        {
            int a;
            cin>>a;
            v.push_back(a);
        }
        int i;
        for(i=n-1;i>0;i--)
        {
            if(v[i-1]>v[i])
                continue;
            else
                break;
        }
        int j;
        for( j=i;j>0;j--)
        {
            if(v[j]>v[j-1])
                continue;
            else
                break;
        }
        cout<<j<<endl;
    }
}


#include<iostream>
#include<math.h>
#include<algorithm>
using namespace std;
int main()
{
    long int t;
    cin>>t;
    while(t--)
    {
        long int n,f;
        cin>>n;
        long long int a[n];
       long long int maxm=INT_MIN;
        for(long int i=0;i<n;i++)
        {
            cin>>a[i];
            maxm=max(maxm,a[i]);

        }
        int i;
        for( i=n-1;i>0;i--)
        {
            if(a[i-1]>=a[i])
            {
                continue;
            }
            else
            {
                f=i;
                break;
            }
        }
        if(i==0)
        {
            cout<<"0"<<endl;
            continue;
        }
        else if(a[f]!=maxm)
        {
            cout<<f-1<<endl;
            continue;
        }else
        {
        int j;
        for(j=f;j>0;j--)
        {
            if(a[j]>a[j-1])
                continue;
            else
                break;
        }
        cout<<j<<endl;
        }
    }
}


#include<iostream>
#include<math.h>
#include<algorithm>
using namespace std;
int main()
{
    long int t;
    cin>>t;
    while(t--)
    {
        long int n,t;
        cin>>n;
        long long int a[n-1];
       long long int maxm=INT_MIN;
        for(int i=0;i<n;i++)
        {
            cin>>a[i];
            maxm=max(maxm,a[i]);

        }
        int i;
        for( i=n-1;i>0;i--)
        {
            if(a[i-1]>=a[i])
            {
                continue;
            }
            else
            {
                t=i;
                break;
            }
        }
        if(i==0)
        {
            cout<<"0"<<endl;
            continue;
        }
        else if(a[t]!=maxm)
        {
            cout<<t-1<<endl;
            continue;
        }else
        {
        int j;
        for(j=t;j>0;j--)
        {
            if(a[j]>a[j-1])
                continue;
            else
                break;
        }
        cout<<j<<endl;
        }
    }
}


#include<iostream>
#include<math.h>
#include<algorithm>
using namespace std;
int main()
{
    long int t;
    cin>>t;
    while(t--)
    {
        long int n,t;
        cin>>n;
        long long int a[n];
       long long int maxm=INT_MIN;
        for(int i=0;i<n;i++)
        {
            cin>>a[i];
            maxm=max(maxm,a[i]);

        }
        int i;
        for( i=n-1;i>0;i--)
        {
            if(a[i-1]>=a[i])
            {
                continue;
            }
            else
            {
                t=i;
                break;
            }
        }
        if(i==0)
        {
            cout<<"0"<<endl;
            continue;
        }
        else if(a[t]!=maxm)
        {
            cout<<t-1<<endl;
            continue;
        }else
        {
        int j;
        for(j=t;j>0;j--)
        {
            if(a[j]>a[j-1])
                continue;
            else
                break;
        }
        cout<<j<<endl;
        }
    }
}


#include<iostream>
#include<vector>
using namespace std;
int main()
{
    int t;
    cin>>t;
    while(t--)
    {
        int n;
        cin>>n;
        vector<int>v;
        for(int i=0;i<n;i++)
        {
            int a;
            cin>>a;
            v.push_back(a);
        }
        int i;
        for(i=n-1;i>0;i--)
        {
            if(v[i-1]>=v[i])
                continue;
            else
                break;
        }
        int j;
        for( j=i;j>0;j--)
        {
            if(v[j]>=v[j-1])
                continue;
            else
                break;
        }
        cout<<j<<endl;
    }
}


#include<iostream>
#include<vector>
using namespace std;
int main()
{
    int t;
    cin>>t;
    while(t--)
    {
        int n;
        cin>>n;
        vector<int>v;
        for(int i=0;i<n;i++)
        {
            int a;
            cin>>a;
            v.push_back(a);
        }
        int i;
        for(i=n-1;i>0;i--)
        {
            if(v[i-1]>=v[i])
                continue;
            else
                break;
        }
        int j;
        for( j=i;j>0;j--)
        {
            if(v[j]>v[j-1])
                continue;
            else
                break;
        }
        cout<<j<<endl;
    }
}


#bitonic array
#we have to check whether the given array is bitonic or not
import sys
input = sys.stdin.buffer.readline
def chb(arr, n) :

	# Check for increasing sequence
	for i in range(1, n) :
		if arr[i] >= arr[i - 1] :
			continue
		else :
			break

	if i == n-1 :
		return True

	# Check for decreasing sequence
	for j in range(i + 1, n) :

		if arr[j] <=arr[j - 1] :
			continue
		else :
			break

	i = j
	if i == n - 1 and arr[n-1]<arr[n-2]:
		return True

	return False

def main():
    n=int(input())
    l=list(map(int,input().split()))
    if n==1:
        return 0
    else:
        for i in range(n):
            tp=l[i:]
            if chb(tp,n-i):
                break
        return i

t=int(input())
while t:
    t-=1
    print(main())


#bitonic array
#we have to check whether the given array is bitonic or not
import sys
input = sys.stdin.buffer.readline

def main():
    n=int(input())
    l=list(map(int,input().split()))
    if n<=2:
        return 0
    else:
        flag=0
        index=0
        for i in range(n-1,0,-1):
            if(l[i]<=l[i-1] and flag==0):
                continue
            if(l[i]>=l[i-1]):
                flag=1
            else:
                index=i
                break

        return index

t=int(input())
while t:
    t-=1
    print(main())


#bitonic array
#we have to check whether the given array is bitonic or not
import sys

def chb(arr, n) :

	# Check for increasing sequence
	for i in range(1, n) :
		if arr[i] >= arr[i - 1] :
			continue
		else :
			break

	if i == n-1 :
		return True

	# Check for decreasing sequence
	for j in range(i + 1, n) :

		if arr[j] <=arr[j - 1] :
			continue
		else :
			break

	i = j
	if i == n - 1 and arr[n-1]<arr[n-2]:
		return True

	return False

def main():
    n=int(input())
    l=list(map(int,input().split()))
    if n==1:
        return 0
    else:
        for i in range(n):
            tp=l[i:]
            if chb(tp,n-i):
                break
        return i

t=int(input())
while t:
    t-=1
    print(main())


#bitonic array
#we have to check whether the given array is bitonic or not
import sys

def chb(arr, n) :

	# Check for increasing sequence
	for i in range(1, n) :
		if arr[i] > arr[i - 1] :
			continue
		else :
			break

	if i == n-1 :
		return True

	# Check for decreasing sequence
	for j in range(i + 1, n) :

		if arr[j] < arr[j - 1] :
			continue
		else :
			break

	i = j
	if i == n - 1 and arr[n-1]<arr[n-2]:
		return True

	return False

def main():
    n=int(input())
    l=list(map(int,input().split()))
    if n==1:
        return 0
    else:
        for i in range(n):
            tp=l[i:]
            if chb(tp,n-i):
                break
        return i

t=int(input())
while t:
    t-=1
    print(main())


t = int(input())

for i in range(t):
    n = int(input())
    a = list(map(int, input().split()))
    counter = -1
    while counter != len(a) * -1:
        if a[counter - 1] >= a[counter]:
            counter -= 1
            continue
        if a[counter - 1] < a[counter]:
            while counter != len(a) * -1:
                if a[counter - 1] <= a[counter]:
                    counter -= 1
                    continue
                else:
                    break
        break
    print(len(a) + counter)


t = int(input())

for i in range(t):
    n = int(input())
    a = list(map(int, input().split()))
    counter = 0
    b = []
    x = len(a)
    a1 = []
    a1 += [i for i in a]
    while len(b) != x:
        b.append(min(a1[0], a1[-1]))
        a1.remove(b[-1])
        if len(b) > 1:
            if b[-1] < b[-2]:
                counter += 1
                b = []
                a.remove(a[0])
                a1 = []
                a1 += [i for i in a]
                x = len(a)
    print(counter)


t = int(input())

for i in range(t):
    n = int(input())
    a = list(map(int, input().split()))
    counter = -1
    while counter != len(a) * -1:
        if a[counter - 1] >= a[counter]:
            counter -= 1
            continue
        if a[counter - 1] < a[counter]:
            while counter != len(a) * -1:
                if a[counter - 1] < a[counter]:
                    counter -= 1
                    continue
                else:
                    break
        break
    print(len(a) + counter)


t = int(input())

for i in range(t):
    n = int(input())
    a = list(map(int, input().split()))
    counter = 0
    x = len(a)
    operations = 0
    while counter != x - 1:
        if a[counter + 1] >= a[counter]:
            counter += 1
            continue
        if a[counter + 1] < a[counter]:
            while counter != x - 1:
                if a[counter + 1] <= a[counter]:
                    counter += 1
                    continue
                else:
                    operations += len(a[0:counter])
                    a = a[counter:]
                    counter = 0
                    x = len(a)
                    break
    print(operations)


t = int(input())

for i in range(t):
    n = int(input())
    a = list(map(int, input().split()))
    counter = 0
    x = len(a)
    operations = 0
    while counter != x - 1:
        if a[counter + 1] >= a[counter]:
            counter += 1
            continue
        if a[counter + 1] < a[counter]:
            while counter != x - 1:
                if a[counter + 1] <= a[counter]:
                    counter += 1
                    continue
                else:
                    a.remove(a[0])
                    operations += 1
                    counter = 0
                    x = len(a)
                    break
    print(operations)


for i in " "*int(input()):
    n,a,k=int(input()),list(map(int,input().split())),n-1
    while k>0 and a[k-1]>=a[k]:k-=1
    while k>0 and a[k-1]<=a[k]:k-=1;print(k)


for _ in " "*int(input()):
  n=int(input())
  a=list(map(int,input().split()))
  prev,nex,curr,ind,f=0,0,0,0,0
  for i in range(n-1,0,-1):
      prev,nex,curr=i-1,i+1,i
      if prev>=0 and nex<n and curr<n:
          if a[prev]>a[curr] and a[nex]>a[curr]:
              print(curr)
              f=1
              break
  if f==0:
    print(0)


for _ in " "*int(input()):
    n,a=int(input()),list(map(int,input().split()))
    k=n-1
    while k>0 and a[k-1]>=a[k]:k-=1
    while k>0 and a[k-1]<=a[k]:k-=1
    print(k)


for _ in " "*int(input()):
  n=int(input())
  a=list(map(int,input().split()))
  lst=[]
  i=0
  j=n-1
  f=0
  ind=0
  while(i!=j):

    if a[i]<a[j]:
      lst.append(a[i])
      i+=1
      if f!=0:
        if lst[-1]<lst[-2]:
          ind = max(ind,i-1)
      if f==0:
        f=1
    else:
      lst.append(a[j])
      j-=1
      if f!=0:
        if lst[-1]<lst[-2]:
          ind = max(ind,j+1)
      if f==0:
        f=1

  print(ind)


for _ in " "*int(input()):
  n=int(input())
  a=list(map(int,input().split()))
  f=0
  for i in range(n-2,0,-1):
      if a[i-1]>a[i] and a[i+1]>=a[i]:
            print(i)
            f=1
            break
  if f==0:
    print(0)


for _ in " "*int(input()):
  n=int(input())
  a=list(map(int,input().split()))
  lst=[]
  i=0
  j=n-1
  f=0
  ind=0
  while(i!=j):
    if a[i]>a[j]:
      lst.append(a[j])
      j-=1
      if f!=0:
        if lst[-1]<lst[-2]:
          ind = max(ind,j+1)
      if f==0:
        f=1
    else:
      lst.append(a[i])
      i+=1
      if f!=0:
        if lst[-1]<lst[-2]:
          ind = max(ind,i-1)
      if f==0:
        f=1
  print(ind)


for _ in " "*int(input()):
  n=int(input())
  a=list(map(int,input().split()))
  f=0
  if len(set(a))==1:
    print(0)
  else:
    for i in range(n-2,0,-1):
        if a[i-1]>=a[i] and a[i+1]>=a[i]:
              print(i)
              f=1
              break
    if f==0:
      print(0)


for i in " "*int(input()):
    n,a=int(input()),list(map(int,input().split()))
    k=n-1
    while k>0 and a[k-1]>=a[k]:k-=1
    while k>0 and a[k-1]<=a[k]:k-=1;print(k)


for i in " "*int(input()):n,a,k=int(input()),list(map(int,input().split())),n-1;while k>0 and a[k-1]>=a[k]:k-=1;while k>0 and a[k-1]<=a[k]:k-=1;print(k)


t=int(input())
while t:
    n=int(input())
    l=list(map(int,input().split()))
    i=j=0
    c=0
    while i<n and j<n:
        c=i
        while j<n-1 and l[j+1]>=l[j]:
            j+=1
        while j<n-1 and l[j+1]<=l[j]:
            j+=1
        i=j

    print(c)

    t-=1


t=int(input())
while t:
    n=int(input())
    l=list(map(int,input().split()))
    i=j=0
    c=0
    while i<n-1 and j<n-1:
        c=i
        while j<n-1 and l[j+1]>=l[j]:
            j+=1
        while j<n-1 and l[j+1]<=l[j]:
            j+=1
        i=j

    if c>n-2:
        print(n-2)
    else:
        print(c)

    t-=1


t=int(input())
while t:
    n=int(input())
    l=list(map(int,input().split()))
    i=j=0
    c=0
    while i<n-1 and j<n-1:
        c=i
        while j<n-1 and l[j+1]>=l[j]:
            j+=1
        while j<n-1 and l[j+1]<=l[j]:
            j+=1
        i=j

    if c>n-2 and n>=2:
        print(n-2)
    else:
        print(c)

    t-=1


t=int(input())
while t:
    n=int(input())
    l=list(map(int,input().split()))
    i=j=0
    c=0
    while i<n-1 and j<n-1:
        c=i
        while j<n-1 and l[j+1]>=l[j]:
            j+=1
        while j<n-1 and l[j+1]<=l[j]:
            j+=1
        i=j

    print(c)

    t-=1


t=int(input())
while t:
    n=int(input())
    l=list(map(int,input().split()))
    i=j=n-1
    while j>0 and l[j-1]>=l[j]:
            j-=1
    while j>0 and l[j-1]<=l[j]:
            j-=1
    if j==-1:
        print(0)
    else:

        print(j)

    t-=1


import sys
input = sys.stdin.readline
INF = float('inf')

tc = int(input())

for _ in range(tc):
    n = int(input())
    arr = list(map(int, input().split()))
    ans = 0
    i = n-1

    while 0 < i:
        if arr[i] > arr[i-1]:
            ans = i - 1
            break
        i -= 1

    j = 0
    while j < i-1:
        if arr[j] > arr[j+1]:
           ans = j + 1
        j += 1

    print(ans)


import java.io.*;
import java.util.*;

public class Task {

	public static void main(String[] args) throws IOException {
		new Task().solve();
	}

	PrintWriter out;
	int cnt = 0;
	int n;
	boolean[] used;
	int[] use;
	ArrayList<Integer>[] rg;
	ArrayList<Integer> tsort = new ArrayList<Integer>();
	int[] comp;
	int[] compsize;
	int[] mt;
	int[] a;
	int k;
	boolean[][] g;
	int dp[];
	int m;
	int[] list;
	void solve() throws IOException{
		Reader in = new Reader("input.txt");
		out = new PrintWriter( new BufferedWriter(new OutputStreamWriter(System.out)) );
		//out = new PrintWriter(new FileWriter(new File("output.txt")));

		int n = in.nextInt();
		int k = in.nextInt();

		int max = 0;

		if (n%2 == 0)
			max = n/2*n;
		else
			max = n/2*n/2+(n/2+1)*(n/2+1);

		if (k > max) {
			System.out.println("NO");
			return;
		}

		int[][] a = new int[n][n];

		int cnt = 0;
		int ind = -1;
		int ind2 = 0;

		for (int i = 0; i < n; i++)
			for (int j = 0; j < n; j++)
			{
				if (i-1 >= 0 && a[i-1][j] == 0)
					a[i][j] = 1;
				else
				if (j-1 >= 0 && a[i][j-1] == 0)
					a[i][j] = 1;
				else
				if (j == 0 && i == 0)
					a[i][j] = 1;

				if (a[i][j] == 1) {
					cnt++;
				}

				if (ind == -1 && cnt == k) {
					ind = i;
					ind2 = j;
				}

			}

		//for (int i = ind2; i < n; i++)
			//a[ind][i] = 1;

		if (ind+1 < n)
			for (int i = ind2; i < n; i++)
				a[ind+1][i] = 1;

		for (int i = ind+2; i < n; i++)
			for (int j = 0; j < n; j++)
				a[i][j] = 1;

		for (int i = 0; i < n; i++) {
			for (int j = 0; j < n; j++) {
				if (a[i][j] == 1)
					out.print("L");
				else
					out.print("S");
			}
			out.println();
		}

		out.flush();
		out.close();

	}

	long pow(int x, int m) {
		if (m == 0)
			return 1;
		return x*pow(x, m-1);
	}

}

	class Pair implements Comparable<Pair> {

		int v;
		int z;
		int i;

		Pair (int v, int z, int i) {
			this.v = v;
			this.z = z;
			this.i = i;
		}

		@Override
		public int compareTo(Pair p) {
			if (v > p.v)
				return 1;
			if (v < p.v)
				return -1;
			return 0;
		}

	}

	class Item implements Comparable<Item> {

		int v;
		int l;
		int z;

		Item(int v, int l, int z) {
			this.v = v;
			this.l = l;
			this.z = z;
		}

		@Override
		public int compareTo(Item item) {

			if (l > item.l)
				return 1;
			else
			if (l < item.l)
				return -1;
			else {
				if (z > item.z)
					return 1;
				else
				if (z < item.z)
					return -1;
				return 0;
			}

		}

	}

	class Reader {

	    StringTokenizer token;
	    BufferedReader in;

	    public Reader(String file) throws IOException {
	        //in = new BufferedReader( new FileReader( file ) );
	        in = new BufferedReader( new InputStreamReader( System.in ) );
	    }

	    public byte nextByte() throws IOException {
	        return Byte.parseByte(Next());
	    }

	    public int nextInt() throws IOException {
	        return Integer.parseInt(Next());
	    }

	    public long nextLong() throws IOException {
	        return Long.parseLong(Next());
	    }

	    public String nextString() throws IOException {
	        return in.readLine();
	    }

	    public String Next() throws IOException {
	        while (token == null || !token.hasMoreTokens()) {
	            token = new StringTokenizer(in.readLine());
	        }
	        return token.nextToken();
	    }

	}


import java.io.*;
import java.util.*;

public class Task {

	public static void main(String[] args) throws IOException {
		new Task().solve();
	}

	PrintWriter out;
	int cnt = 0;
	int n;
	boolean[] used;
	int[] use;
	ArrayList<Integer>[] rg;
	ArrayList<Integer> tsort = new ArrayList<Integer>();
	int[] comp;
	int[] compsize;
	int[] mt;
	int[] a;
	int k;
	boolean[][] g;
	int dp[];
	int m;
	int[] list;
	void solve() throws IOException{
		Reader in = new Reader("input.txt");
		out = new PrintWriter( new BufferedWriter(new OutputStreamWriter(System.out)) );
		//out = new PrintWriter(new FileWriter(new File("output.txt")));

		int n = in.nextInt();
		int k = in.nextInt();

		int max = 0;

		if (n%2 == 0)
			max = n/2*n;
		else
			max = n/2*n/2+(n/2+1)*(n/2+1);

		if (k > max) {
			System.out.println("NO");
			return;
		}

		int[][] a = new int[n][n];

		int cnt = 0;
		int ind = -1;
		int ind2 = 0;

		if (k == 0) {
			System.out.println("YES");

			for (int i = 0; i < n; i++) {
				for (int j = 0; j < n; j++) {
					if (a[i][j] == 1)
						out.print("L");
					else
						out.print("S");
				}
				out.println();
			}
			out.flush();
			out.close();
			return;
		}

		for (int i = 0; i < n; i++)
			for (int j = 0; j < n; j++)
			{
				if (i-1 >= 0 && a[i-1][j] == 0)
					a[i][j] = 1;
				else
				if (j-1 >= 0 && a[i][j-1] == 0)
					a[i][j] = 1;
				else
				if (j == 0 && i == 0)
					a[i][j] = 1;

				if (a[i][j] == 1) {
					cnt++;
				}

				if (ind == -1 && cnt == k) {
					ind = i;
					ind2 = j;
				}

			}

		//for (int i = ind2; i < n; i++)
			//a[ind][i] = 1;

		if (ind+1 < n)
			for (int i = ind2; i < n; i++)
				a[ind+1][i] = 1;

		for (int i = ind+2; i < n; i++)
			for (int j = 0; j < n; j++)
				a[i][j] = 1;

		if (ind == n-1)
			for (int i = ind2+2; i < n; i++)
				if (ind-1 >= 0 && a[ind-1][i] == 1 || i == n-1)
					a[ind][i] = 1;
				else
					a[ind][i] = 0;

		System.out.println("YES");

		for (int i = 0; i < n; i++) {
			for (int j = 0; j < n; j++) {
				if (a[i][j] == 1)
					out.print("L");
				else
					out.print("S");
			}
			out.println();
		}

		out.flush();
		out.close();

	}

	long pow(int x, int m) {
		if (m == 0)
			return 1;
		return x*pow(x, m-1);
	}

}

	class Pair implements Comparable<Pair> {

		int v;
		int z;
		int i;

		Pair (int v, int z, int i) {
			this.v = v;
			this.z = z;
			this.i = i;
		}

		@Override
		public int compareTo(Pair p) {
			if (v > p.v)
				return 1;
			if (v < p.v)
				return -1;
			return 0;
		}

	}

	class Item implements Comparable<Item> {

		int v;
		int l;
		int z;

		Item(int v, int l, int z) {
			this.v = v;
			this.l = l;
			this.z = z;
		}

		@Override
		public int compareTo(Item item) {

			if (l > item.l)
				return 1;
			else
			if (l < item.l)
				return -1;
			else {
				if (z > item.z)
					return 1;
				else
				if (z < item.z)
					return -1;
				return 0;
			}

		}

	}

	class Reader {

	    StringTokenizer token;
	    BufferedReader in;

	    public Reader(String file) throws IOException {
	        //in = new BufferedReader( new FileReader( file ) );
	        in = new BufferedReader( new InputStreamReader( System.in ) );
	    }

	    public byte nextByte() throws IOException {
	        return Byte.parseByte(Next());
	    }

	    public int nextInt() throws IOException {
	        return Integer.parseInt(Next());
	    }

	    public long nextLong() throws IOException {
	        return Long.parseLong(Next());
	    }

	    public String nextString() throws IOException {
	        return in.readLine();
	    }

	    public String Next() throws IOException {
	        while (token == null || !token.hasMoreTokens()) {
	            token = new StringTokenizer(in.readLine());
	        }
	        return token.nextToken();
	    }

	}


import java.io.*;
import java.util.*;

public class Task {

	public static void main(String[] args) throws IOException {
		new Task().solve();
	}

	PrintWriter out;
	int cnt = 0;
	int n;
	boolean[] used;
	int[] use;
	ArrayList<Integer>[] rg;
	ArrayList<Integer> tsort = new ArrayList<Integer>();
	int[] comp;
	int[] compsize;
	int[] mt;
	int[] a;
	int k;
	boolean[][] g;
	int dp[];
	int m;
	int[] list;
	void solve() throws IOException{
		Reader in = new Reader("input.txt");
		out = new PrintWriter( new BufferedWriter(new OutputStreamWriter(System.out)) );
		//out = new PrintWriter(new FileWriter(new File("output.txt")));

		int n = in.nextInt();
		int k = in.nextInt();

		int max = 0;

		if (n%2 == 0)
			max = n/2*n;
		else
			max = n/2*n/2+(n/2+1)*(n/2+1);

		if (k > max) {
			System.out.println("NO");
			return;
		}

		int[][] a = new int[n][n];

		int cnt = 0;
		int ind = -1;
		int ind2 = 0;

		if (k == 0) {
			System.out.println("YES");

			for (int i = 0; i < n; i++) {
				for (int j = 0; j < n; j++) {
					if (a[i][j] == 1)
						out.print("L");
					else
						out.print("S");
				}
				out.println();
			}
			out.flush();
			out.close();
			return;
		}

		for (int i = 0; i < n; i++)
			for (int j = 0; j < n; j++)
			{
				if (i-1 >= 0 && a[i-1][j] == 0)
					a[i][j] = 1;
				else
				if (j-1 >= 0 && a[i][j-1] == 0)
					a[i][j] = 1;
				else
				if (j == 0 && i == 0)
					a[i][j] = 1;

				if (a[i][j] == 1) {
					cnt++;
				}

				if (ind == -1 && cnt == k) {
					ind = i;
					ind2 = j;
				}

			}

		//for (int i = ind2; i < n; i++)
			//a[ind][i] = 1;

		if (ind+1 < n)
			for (int i = ind2; i < n; i++)
				a[ind+1][i] = 1;

		for (int i = ind+2; i < n; i++)
			for (int j = 0; j < n; j++)
				a[i][j] = 1;

		if (ind == n-1)
			for (int i = ind2+2; i < n; i++)
				if (ind-1 >= 0 && a[ind-1][i] == 1 || i == n-1)
					a[ind][i] = 1;
				else
					a[ind][i] = 0;

		System.out.println("YES");

		for (int i = 0; i < n; i++) {
			for (int j = 0; j < n; j++) {
				if (a[i][j] == 1)
					out.print("L");
				else
					out.print("S");
			}
			out.println();
		}

		out.flush();
		out.close();

	}

	long pow(int x, int m) {
		if (m == 0)
			return 1;
		return x*pow(x, m-1);
	}

}

	class Pair implements Comparable<Pair> {

		int v;
		int z;
		int i;

		Pair (int v, int z, int i) {
			this.v = v;
			this.z = z;
			this.i = i;
		}

		@Override
		public int compareTo(Pair p) {
			if (v > p.v)
				return 1;
			if (v < p.v)
				return -1;
			return 0;
		}

	}

	class Item implements Comparable<Item> {

		int v;
		int l;
		int z;

		Item(int v, int l, int z) {
			this.v = v;
			this.l = l;
			this.z = z;
		}

		@Override
		public int compareTo(Item item) {

			if (l > item.l)
				return 1;
			else
			if (l < item.l)
				return -1;
			else {
				if (z > item.z)
					return 1;
				else
				if (z < item.z)
					return -1;
				return 0;
			}

		}

	}

	class Reader {

	    StringTokenizer token;
	    BufferedReader in;

	    public Reader(String file) throws IOException {
	        //in = new BufferedReader( new FileReader( file ) );
	        in = new BufferedReader( new InputStreamReader( System.in ) );
	    }

	    public byte nextByte() throws IOException {
	        return Byte.parseByte(Next());
	    }

	    public int nextInt() throws IOException {
	        return Integer.parseInt(Next());
	    }

	    public long nextLong() throws IOException {
	        return Long.parseLong(Next());
	    }

	    public String nextString() throws IOException {
	        return in.readLine();
	    }

	    public String Next() throws IOException {
	        while (token == null || !token.hasMoreTokens()) {
	            token = new StringTokenizer(in.readLine());
	        }
	        return token.neimport java.io.*;
import java.util.*;

public class Task {

	public static void main(String[] args) throws IOException {
		new Task().solve();
	}

	PrintWriter out;
	int cnt = 0;
	int n;
	boolean[] used;
	int[] use;
	ArrayList<Integer>[] rg;
	ArrayList<Integer> tsort = new ArrayList<Integer>();
	int[] comp;
	int[] compsize;
	int[] mt;
	int[] a;
	int k;
	boolean[][] g;
	int dp[];
	int m;
	int[] list;
	void solve() throws IOException{
		Reader in = new Reader("input.txt");
		out = new PrintWriter( new BufferedWriter(new OutputStreamWriter(System.out)) );
		//out = new PrintWriter(new FileWriter(new File("output.txt")));

		int n = in.nextInt();
		int k = in.nextInt();

		int max = 0;

		if (n%2 == 0)
			max = n/2*n;
		else
			max = n/2*n/2+(n/2+1)*(n/2+1);

		if (k > max) {
			System.out.println("NO");
			return;
		}

		int[][] a = new int[n][n];

		int cnt = 0;
		int ind = -1;
		int ind2 = 0;

		if (k == 0) {
			System.out.println("YES");

			for (int i = 0; i < n; i++) {
				for (int j = 0; j < n; j++) {
					if (a[i][j] == 1)
						out.print("L");
					else
						out.print("S");
				}
				out.println();
			}
			out.flush();
			out.close();
			return;
		}

		for (int i = 0; i < n; i++)
			for (int j = 0; j < n; j++)
			{
				if (i-1 >= 0 && a[i-1][j] == 0)
					a[i][j] = 1;
				else
				if (j-1 >= 0 && a[i][j-1] == 0)
					a[i][j] = 1;
				else
				if (j == 0 && i == 0)
					a[i][j] = 1;

				if (a[i][j] == 1) {
					cnt++;
				}

				if (ind == -1 && cnt == k) {
					ind = i;
					ind2 = j;
				}

			}

		//for (int i = ind2; i < n; i++)
			//a[ind][i] = 1;

		if (ind+1 < n)
			for (int i = ind2; i < n; i++)
				a[ind+1][i] = 1;

		for (int i = ind+2; i < n; i++)
			for (int j = 0; j < n; j++)
				a[i][j] = 1;

		if (ind == n-1)
			for (int i = ind2+2; i < n; i++)
				if (ind-1 >= 0 && a[ind-1][i] == 1 || i == n-1)
					a[ind][i] = 1;
				else
					a[ind][i] = 0;

		System.out.println("YES");

		for (int i = 0; i < n; i++) {
			for (int j = 0; j < n; j++) {
				if (a[i][j] == 1)
					out.print("L");
				else
					out.print("S");
			}
			out.println();
		}

		out.flush();
		out.close();

	}

	long pow(int x, int m) {
		if (m == 0)
			return 1;
		return x*pow(x, m-1);
	}

}

	class Pair implements Comparable<Pair> {

		int v;
		int z;
		int i;

		Pair (int v, int z, int i) {
			this.v = v;
			this.z = z;
			this.i = i;
		}

		@Override
		public int compareTo(Pair p) {
			if (v > p.v)
				return 1;
			if (v < p.v)
				return -1;
			return 0;
		}

	}

	class Item implements Comparable<Item> {

		int v;
		int l;
		int z;

		Item(int v, int l, int z) {
			this.v = v;
			this.l = l;
			this.z = z;
		}

		@Override
		public int compareTo(Item item) {

			if (l > item.l)
				return 1;
			else
			if (l < item.l)
				return -1;
			else {
				if (z > item.z)
					return 1;
				else
				if (z < item.z)
					return -1;
				return 0;
			}

		}

	}

	class Reader {

	    StringTokenizer token;
	    BufferedReader in;

	    public Reader(String file) throws IOException {
	        //in = new BufferedReader( new FileReader( file ) );
	        in = new BufferedReader( new InputStreamReader( System.in ) );
	    }

	    public byte nextByte() throws IOException {
	        return Byte.parseByte(Next());
	    }

	    public int nextInt() throws IOException {
	        return Integer.parseInt(Next());
	    }

	    public long nextLong() throws IOException {
	        return Long.parseLong(Next());
	    }

	    public String nextString() throws IOException {
	        return in.readLine();
	    }

	    public String Next() throws IOException {
	        while (token == null || !token.hasMoreTokens()) {
	            token = new StringTokenizer(in.readLine());
	        }
	        return token.nextToken();
	    }

	}

xtToken();
	    }

	}


import java.io.*;
import java.util.*;

public class Task {

	public static void main(String[] args) throws IOException {
		new Task().solve();
	}

	PrintWriter out;
	int cnt = 0;
	int n;
	boolean[] used;
	int[] use;
	ArrayList<Integer>[] rg;
	ArrayList<Integer> tsort = new ArrayList<Integer>();
	int[] comp;
	int[] compsize;
	int[] mt;
	int[] a;
	int k;
	boolean[][] g;
	int dp[];
	int m;
	int[] list;
	void solve() throws IOException{
		Reader in = new Reader("input.txt");
		out = new PrintWriter( new BufferedWriter(new OutputStreamWriter(System.out)) );
		//out = new PrintWriter(new FileWriter(new File("output.txt")));

		int n = in.nextInt();
		int k = in.nextInt();

		int max = 0;

		if (n%2 == 0)
			max = n/2*n;
		else
			max = n/2*n/2+(n/2+1)*(n/2+1);

		if (k > max) {
			System.out.println("NO");
			return;
		}

		int[][] a = new int[n][n];

		int cnt = 0;
		int ind = -1;
		int ind2 = 0;

		if (k == 0) {
			System.out.println("YES");

			for (int i = 0; i < n; i++) {
				for (int j = 0; j < n; j++) {
					if (a[i][j] == 1)
						out.print("L");
					else
						out.print("S");
				}
				out.println();
			}
			out.flush();
			out.close();
			return;
		}

		for (int i = 0; i < n; i++)
			for (int j = 0; j < n; j++)
			{
				if (i-1 >= 0 && a[i-1][j] == 0)
					a[i][j] = 1;
				else
				if (j-1 >= 0 && a[i][j-1] == 0)
					a[i][j] = 1;
				else
				if (j == 0 && i == 0)
					a[i][j] = 1;

				if (a[i][j] == 1) {
					cnt++;
				}

				if (ind == -1 && cnt == k) {
					ind = i;
					ind2 = j;
				}

			}

		//for (int i = ind2; i < n; i++)
			//a[ind][i] = 1;

		if (ind+1 < n)
			for (int i = ind2; i < n; i++)
				a[ind+1][i] = 1;

		for (int i = ind+2; i < n; i++)
			for (int j = 0; j < n; j++)
				a[i][j] = 1;

		if (ind == n-1)
			for (int i = ind2+2; i < n; i++)
				a[ind][i] = 0;

		System.out.println("YES");

		for (int i = 0; i < n; i++) {
			for (int j = 0; j < n; j++) {
				if (a[i][j] == 1)
					out.print("L");
				else
					out.print("S");
			}
			out.println();
		}

		out.flush();
		out.close();

	}

	long pow(int x, int m) {
		if (m == 0)
			return 1;
		return x*pow(x, m-1);
	}

}

	class Pair implements Comparable<Pair> {

		int v;
		int z;
		int i;

		Pair (int v, int z, int i) {
			this.v = v;
			this.z = z;
			this.i = i;
		}

		@Override
		public int compareTo(Pair p) {
			if (v > p.v)
				return 1;
			if (v < p.v)
				return -1;
			return 0;
		}

	}

	class Item implements Comparable<Item> {

		int v;
		int l;
		int z;

		Item(int v, int l, int z) {
			this.v = v;
			this.l = l;
			this.z = z;
		}

		@Override
		public int compareTo(Item item) {

			if (l > item.l)
				return 1;
			else
			if (l < item.l)
				return -1;
			else {
				if (z > item.z)
					return 1;
				else
				if (z < item.z)
					return -1;
				return 0;
			}

		}

	}

	class Reader {

	    StringTokenizer token;
	    BufferedReader in;

	    public Reader(String file) throws IOException {
	        //in = new BufferedReader( new FileReader( file ) );
	        in = new BufferedReader( new InputStreamReader( System.in ) );
	    }

	    public byte nextByte() throws IOException {
	        return Byte.parseByte(Next());
	    }

	    public int nextInt() throws IOException {
	        return Integer.parseInt(Next());
	    }

	    public long nextLong() throws IOException {
	        return Long.parseLong(Next());
	    }

	    public String nextString() throws IOException {
	        return in.readLine();
	    }

	    public String Next() throws IOException {
	        while (token == null || !token.hasMoreTokens()) {
	            token = new StringTokenizer(in.readLine());
	        }
	        return token.nextToken();
	    }

	}


import java.io.*;
import java.util.*;

public class Task {

	public static void main(String[] args) throws IOException {
		new Task().solve();
	}

	PrintWriter out;
	int cnt = 0;
	int n;
	boolean[] used;
	int[] use;
	ArrayList<Integer>[] rg;
	ArrayList<Integer> tsort = new ArrayList<Integer>();
	int[] comp;
	int[] compsize;
	int[] mt;
	int[] a;
	int k;
	boolean[][] g;
	int dp[];
	int m;
	int[] list;
	void solve() throws IOException{
		Reader in = new Reader("input.txt");
		out = new PrintWriter( new BufferedWriter(new OutputStreamWriter(System.out)) );
		//out = new PrintWriter(new FileWriter(new File("output.txt")));

		int n = in.nextInt();
		int k = in.nextInt();

		int max = 0;

		if (n%2 == 0)
			max = n/2*n;
		else
			max = n/2*n/2+(n/2+1)*(n/2+1);

		if (k > max) {
			System.out.println("NO");
			return;
		}

		int[][] a = new int[n][n];

		int cnt = 0;
		int ind = -1;
		int ind2 = 0;

		if (k == 0) {
			System.out.println("YES");

			for (int i = 0; i < n; i++) {
				for (int j = 0; j < n; j++) {
					if (a[i][j] == 1)
						out.print("L");
					else
						out.print("S");
				}
				out.println();
			}
			out.flush();
			out.close();
			return;
		}

		for (int i = 0; i < n; i++)
			for (int j = 0; j < n; j++)
			{
				if (i-1 >= 0 && a[i-1][j] == 0)
					a[i][j] = 1;
				else
				if (j-1 >= 0 && a[i][j-1] == 0)
					a[i][j] = 1;
				else
				if (j == 0 && i == 0)
					a[i][j] = 1;

				if (a[i][j] == 1) {
					cnt++;
				}

				if (ind == -1 && cnt == k) {
					ind = i;
					ind2 = j;
				}

			}

		//for (int i = ind2; i < n; i++)
			//a[ind][i] = 1;

		if (ind+1 < n)
			for (int i = ind2; i < n; i++)
				a[ind+1][i] = 1;

		for (int i = ind+2; i < n; i++)
			for (int j = 0; j < n; j++)
				a[i][j] = 1;

		System.out.println("YES");

		for (int i = 0; i < n; i++) {
			for (int j = 0; j < n; j++) {
				if (a[i][j] == 1)
					out.print("L");
				else
					out.print("S");
			}
			out.println();
		}

		out.flush();
		out.close();

	}

	long pow(int x, int m) {
		if (m == 0)
			return 1;
		return x*pow(x, m-1);
	}

}

	class Pair implements Comparable<Pair> {

		int v;
		int z;
		int i;

		Pair (int v, int z, int i) {
			this.v = v;
			this.z = z;
			this.i = i;
		}

		@Override
		public int compareTo(Pair p) {
			if (v > p.v)
				return 1;
			if (v < p.v)
				return -1;
			return 0;
		}

	}

	class Item implements Comparable<Item> {

		int v;
		int l;
		int z;

		Item(int v, int l, int z) {
			this.v = v;
			this.l = l;
			this.z = z;
		}

		@Override
		public int compareTo(Item item) {

			if (l > item.l)
				return 1;
			else
			if (l < item.l)
				return -1;
			else {
				if (z > item.z)
					return 1;
				else
				if (z < item.z)
					return -1;
				return 0;
			}

		}

	}

	class Reader {

	    StringTokenizer token;
	    BufferedReader in;

	    public Reader(String file) throws IOException {
	        //in = new BufferedReader( new FileReader( file ) );
	        in = new BufferedReader( new InputStreamReader( System.in ) );
	    }

	    public byte nextByte() throws IOException {
	        return Byte.parseByte(Next());
	    }

	    public int nextInt() throws IOException {
	        return Integer.parseInt(Next());
	    }

	    public long nextLong() throws IOException {
	        return Long.parseLong(Next());
	    }

	    public String nextString() throws IOException {
	        return in.readLine();
	    }

	    public String Next() throws IOException {
	        while (token == null || !token.hasMoreTokens()) {
	            token = new StringTokenizer(in.readLine());
	        }
	        return token.nextToken();
	    }

	}


import java.util.Arrays;
import java.util.Scanner;

public class B {
	MyScanner sc = new MyScanner();
	Scanner sc2 = new Scanner(System.in);
	long start = System.currentTimeMillis();
	long fin = System.currentTimeMillis();
	final int MOD = 1000000007;
	int[] dx = { 1, 0, 0, -1 };
	int[] dy = { 0, 1, -1, 0 };

	void run() {
		int n = sc.nextInt();
		int k = sc.nextInt();
		char[][] f = new char[n][n];
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < n; j++) {
				f[i][j] = 'S';
			}
		}
		int cnt = 0;
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < n; j++) {
				if (i % 2 == 0) {
					if (j % 2 == 0) {
						f[i][j] = 'L';
						cnt++;
					}
				} else {
					if (j % 2 == 1) {
						f[i][j] = 'L';
						cnt++;
					}
				}
			}
		}
		if (cnt < k) {
			System.out.println("NO");
		} else {
			System.out.println("YES");
			L: for (int i = 0; i < n; i++) {
				for (int j = 0; j < n; j++) {
					if (cnt == k) {
						break L;
					}
					if (f[i][j] == 'L') {
						f[i][j] = 'S';
						cnt--;
					}
				}
			}
			debug2(f);
		}
	}

	public static void main(String[] args) {
		new B().run();
	}

	void debug(Object... o) {
		System.out.println(Arrays.deepToString(o));
	}

	void debug2(char[][] array) {
		for (int i = 0; i < array.length; i++) {
			for (int j = 0; j < array[i].length; j++) {
				System.out.print(array[i][j]);
			}
			System.out.println();
		}
	}

	boolean inner(int h, int w, int limH, int limW) {
		return 0 <= h && h < limH && 0 <= w && w < limW;
	}

	void swap(int[] x, int a, int b) {
		int tmp = x[a];
		x[a] = x[b];
		x[b] = tmp;
	}

	// find minimum i (a[i] >= border)
	int lower_bound(int a[], int border) {
		int l = -1;
		int r = a.length;
		while (r - l > 1) {
			int mid = (l + r) / 2;
			if (border <= a[mid]) {
				r = mid;
			} else {
				l = mid;
			}
		}
		// r = l + 1
		return r;
	}

	boolean palindrome(String s) {
		for (int i = 0; i < s.length() / 2; i++) {
			if (s.charAt(i) != s.charAt(s.length() - 1 - i)) {
				return false;
			}
		}
		return true;
	}

	class MyScanner {
		int nextInt() {
			try {
				int c = System.in.read();
				while (c != '-' && (c < '0' || '9' < c))
					c = System.in.read();
				if (c == '-')
					return -nextInt();
				int res = 0;
				do {
					res *= 10;
					res += c - '0';
					c = System.in.read();
				} while ('0' <= c && c <= '9');
				return res;
			} catch (Exception e) {
				return -1;
			}
		}

		double nextDouble() {
			return Double.parseDouble(next());
		}

		long nextLong() {
			return Long.parseLong(next());
		}

		String next() {
			try {
				StringBuilder res = new StringBuilder("");
				int c = System.in.read();
				while (Character.isWhitespace(c))
					c = System.in.read();
				do {
					res.append((char) c);
				} while (!Character.isWhitespace(c = System.in.read()));
				return res.toString();
			} catch (Exception e) {
				return null;
			}
		}

		int[] nextIntArray(int n) {
			int[] in = new int[n];
			for (int i = 0; i < n; i++) {
				in[i] = nextInt();
			}
			return in;
		}

		int[][] nextInt2dArray(int n, int m) {
			int[][] in = new int[n][m];
			for (int i = 0; i < n; i++) {
				in[i] = nextIntArray(m);
			}
			return in;
		}

		double[] nextDoubleArray(int n) {
			double[] in = new double[n];
			for (int i = 0; i < n; i++) {
				in[i] = nextDouble();
			}
			return in;
		}

		long[] nextLongArray(int n) {
			long[] in = new long[n];
			for (int i = 0; i < n; i++) {
				in[i] = nextLong();
			}
			return in;
		}

		char[][] nextCharField(int n, int m) {
			char[][] in = new char[n][m];
			for (int i = 0; i < n; i++) {
				String s = sc.next();
				for (int j = 0; j < m; j++) {
					in[i][j] = s.charAt(j);
				}
			}
			return in;
		}
	}
}


import java.util.Scanner;

public class B {
	Scanner sc = new Scanner(System.in);

	void run() {
		int n = sc.nextInt();
		int k = sc.nextInt();
		int cnt = (n * n + 1) / 2;
		if (cnt < k) {
			System.out.println("NO");
			return;
		}
		char[][] f = new char[n][n];
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < n; j++) {
				if (i % 2 == 0) {
					f[i][j] = (j % 2 == 0) ? 'L' : 'S';
				} else {
					f[i][j] = (j % 2 == 1) ? 'L' : 'S';
				}
			}
		}
		L: for (int i = 0; i < n; i++) {
			for (int j = 0; j < n; j++) {
				if (cnt == k) {
					break L;
				}
				if (f[i][j] == 'L') {
					f[i][j] = 'S';
					cnt--;
				}
			}
		}
		out(f);
	}

	public static void main(String[] args) {
		new B().run();
	}

	void out(char[][] array) {
		StringBuilder sb = new StringBuilder("YES\n");
		for (int i = 0; i < array.length; i++) {
			for (int j = 0; j < array[i].length; j++) {
				sb.append(array[i][j]);
			}
			sb.append("\n");
		}
		System.out.print(sb);
	}

}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

/**
 *
 *
SSSSS  fill
LLSLL
SSSSS  fill
LLSLL
SSSSS  fill

5/2 = 2
4/2 = 2-1 = 1

n = the number of programmers
m = the number of lines of code in the task
b =  the maximum total number of bugs respectively
mod = the modulo you should use when printing the answer

3 3 3 100
1 1 1
n = 3; m = 3; b = 3; mod = 100;
1 + 1 + 1 = 3 +1 total = 10
3 + 0 + 0 = 3 +3
2 + 0 + 1 = 3 +6

n=1   1*1 + 0
S

n=2 k=2
LS
SL

n=3 k=5  2*2 + 1*1 = 5
LSL
SLS
LSL

n=4 k=8
LSLS
SLSL
LSLS
SLSL

n=5 k=13 = 3*3 + 2*2 = 13
LSLSL
SLSLS
LSLSL
SLSLS
LSLSL

n=6 k=18
LSLSLS
SLSLSL
LSLSLS
SLSLSL
LSLSLS
SLSLSL

n=7 k= 25 = 4*4 + 3*3
LSLSLSL*
SLSLSLS-
LSLSLSL*
SLSLSLS-
LSLSLSL*
SLSLSLS-
LSLSLSL*
 *
 * */
public class B_Div2_302 {
    public static void main(String[]arg) throws IOException
    {
        new B_Div2_302().solve();
    }
    public void solve()throws IOException
    {
        BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st = new StringTokenizer(in.readLine());
        int N,K,a,b;
        N = Integer.parseInt(st.nextToken());
        K = Integer.parseInt(st.nextToken());
        if((N&1) == 0)
        {
            a = (N*N)/2;
            if(a >= K)
            {
                System.out.println("YES");
                System.out.print(map(N, K));
            }
            else
                System.out.println("NO");
        }
        else
        {
            a = (N/2) + 1;
            b = N/2;
            if((a*a + b*b) >= K)
            {
                System.out.println("YES");
                System.out.print(map(N, K));
            }
            else
                System.out.println("NO");
        }
    }
    private String map(int n, int k)
    {
        int i,j;
        String ans = "";
        for(i = 0; i < n; i++)
        {
            if(k > 0)
            {
                if((i&1)==0)
                {
                    for(j = 0; j < n; j++)
                    {
                        if((j&1) == 0 && k > 0)
                        {
                            ans += "L";
                            k--;
                        }
                        else
                            ans += "S";
                    }
                    ans += "\n";
                }
                else
                {
                    for(j = 0; j < n; j++)
                    {
                        if((j&1) == 1 && k > 0)
                        {
                            ans += "L";
                            k--;
                        }
                        else
                            ans += "S";
                    }
                    ans += "\n";
                }
            }
            else
            {
                for(j = 0; j < n; j++)
                {
                    ans += "S";
                }
                ans += "\n";
            }
        }
        return ans;
    }
}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

/**
 *
 *
SSSSS  fill
LLSLL
SSSSS  fill
LLSLL
SSSSS  fill

5/2 = 2
4/2 = 2-1 = 1

n = the number of programmers
m = the number of lines of code in the task
b =  the maximum total number of bugs respectively
mod = the modulo you should use when printing the answer

3 3 3 100
1 1 1
n = 3; m = 3; b = 3; mod = 100;
1 + 1 + 1 = 3 +1 total = 10
3 + 0 + 0 = 3 +3
2 + 0 + 1 = 3 +6

n=1
S

n=2 k=2
LS
SL

n=3 k=5  2*2 + 1*1 = 5
LSL
SLS
LSL

n=4 k=8
LSLS
SLSL
LSLS
SLSL

n=5 k=13 = 3*3 + 2*2 = 13
LSLSL
SLSLS
LSLSL
SLSLS
LSLSL

n=6 k=18
LSLSLS
SLSLSL
LSLSLS
SLSLSL
LSLSLS
SLSLSL

n=7 k= 25 = 4*4 + 3*3
LSLSLSL*
SLSLSLS-
LSLSLSL*
SLSLSLS-
LSLSLSL*
SLSLSLS-
LSLSLSL*
 *
 * */
public class B_Div2_302 {
	public static void main(String[]arg) throws IOException
	{
		new B_Div2_302().solve();
	}
	public void solve()throws IOException
	{
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st = new StringTokenizer(in.readLine());
		int N,K,a,b;
		N = Integer.parseInt(st.nextToken());
		K = Integer.parseInt(st.nextToken());
		if(N == 1 && K == 0)
		{
			System.out.println("YES");
			System.out.println("S");
		}
		else if(N == 1 && K > 0)
			System.out.println("NO");
		else
		{
			if((N&1) == 0)
			{
				a = (N*N)/2;
				if(a >= K)
				{
					System.out.println("YES");
					System.out.print(map(N, K));
				}
				else
					System.out.println("NO");
			}
			else
			{
				a = (N/2) + 1;
				b = N/2;
				if((a*a + b*b) >= K)
				{
					System.out.println("YES");
					System.out.print(map(N, K));
				}
				else
					System.out.println("NO");
			}
		}
	}
	private String map(int n, int k)
	{
		int i,j;
		String ans = "";
		for(i = 0; i < n; i++)
		{
			if(k > 0)
			{
				if((i&1)==0)
				{
					for(j = 0; j < n; j++)
					{
						if((j&1) == 0 && k > 0)
						{
							ans += "L";
							k--;
						}
						else
							ans += "S";
					}
					ans += "\n";
				}
				else
				{
					for(j = 0; j < n; j++)
					{
						if((j&1) == 1 && k > 0)
						{
							ans += "L";
							k--;
						}
						else
							ans += "S";
					}
					ans += "\n";
				}
			}
			else
			{
				for(j = 0; j < n; j++)
				{
					ans += "S";
				}
				ans += "\n";
			}
		}
		return ans;
	}
}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

/**
 *
 *
SSSSS  fill
LLSLL
SSSSS  fill
LLSLL
SSSSS  fill

5/2 = 2
4/2 = 2-1 = 1

n = the number of programmers
m = the number of lines of code in the task
b =  the maximum total number of bugs respectively
mod = the modulo you should use when printing the answer

3 3 3 100
1 1 1
n = 3; m = 3; b = 3; mod = 100;
1 + 1 + 1 = 3 +1 total = 10
3 + 0 + 0 = 3 +3
2 + 0 + 1 = 3 +6

n=1
S

n=2 k=2
LS
SL

n=3 k=5  2*2 + 1*1 = 5
LSL
SLS
LSL

n=4 k=8
LSLS
SLSL
LSLS
SLSL

n=5 k=13 = 3*3 + 2*2 = 13
LSLSL
SLSLS
LSLSL
SLSLS
LSLSL

n=6 k=18
LSLSLS
SLSLSL
LSLSLS
SLSLSL
LSLSLS
SLSLSL

n=7 k= 25 = 4*4 + 3*3
LSLSLSL*
SLSLSLS-
LSLSLSL*
SLSLSLS-
LSLSLSL*
SLSLSLS-
LSLSLSL*
 *
 * */
public class B_Div2_302 {
	public static void main(String[]arg) throws IOException
	{
		new B_Div2_302().solve();
	}
	public void solve()throws IOException
	{
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st = new StringTokenizer(in.readLine());
		int N,K,a,b;
		N = Integer.parseInt(st.nextToken());
		K = Integer.parseInt(st.nextToken());
		if(N == 1)
		{
			System.out.println("NO");
		}
		else
		{
			if((N&1) == 0)
			{
				a = (N*N)/2;
				if(a >= K)
				{
					System.out.println("YES");
					System.out.print(map(N, K));
				}
				else
					System.out.println("NO");
			}
			else
			{
				a = (N/2) + 1;
				b = N/2;
				if((a*a + b*b) >= K)
				{
					System.out.println("YES");
					System.out.print(map(N, K));
				}
				else
					System.out.println("NO");
			}
		}
	}
	private String map(int n, int k)
	{
		int i,j;
		String ans = "";
		for(i = 0; i < n; i++)
		{
			if(k > 0)
			{
				if((i&1)==0)
				{
					for(j = 0; j < n; j++)
					{
						if((j&1) == 0 && k > 0)
						{
							ans += "L";
							k--;
						}
						else
							ans += "S";
					}
					ans += "\n";
				}
				else
				{
					for(j = 0; j < n; j++)
					{
						if((j&1) == 1 && k > 0)
						{
							ans += "L";
							k--;
						}
						else
							ans += "S";
					}
					ans += "\n";
				}
			}
			else
			{
				for(j = 0; j < n; j++)
				{
					ans += "S";
				}
				ans += "\n";
			}
		}
		return ans;
	}
}


import java.io.*;
import java.util.*;

public class CF302_2 {
  public static void main (String [] args) throws IOException {
      Scanner sc = new Scanner(System.in);
      PrintWriter out = new PrintWriter(new BufferedOutputStream(System.out));

      int n = sc.nextInt();
      int k = sc.nextInt();
      int max = 0;
      if (n%2 == 0) {
          max = n*n/2;
      } else {
          max = (n*n+1)/2;
      }

      if (max < k) {
          out.println("NO");
      } else {
          out.println("YES");
          int place = 0;
          int count = 1;
          for (int x = 0; x < n; x++) {
              for (int y = 0; y < n; y++) {
                  if (y == n-1) {
                      if (place%2 == 0 && count <= k) {
                        out.println("L");
                        place++;
                        count++;
                      } else {
                        out.println("S");
                        place++;
                      }
                  } else {
                      if (place%2 == 0 && count <= k) {
                        out.print("L");
                        place++;
                        count++;
                      } else {
                        out.print("S");
                        place++;
                      }
                  }
              }
          }
      }

      out.close();
      System.exit(0);
  }
}


import java.io.*;
import java.util.*;

public class CF302_2 {
  public static void main (String [] args) throws IOException {
      Scanner sc = new Scanner(System.in);
      PrintWriter out = new PrintWriter(new BufferedOutputStream(System.out));

      int n = sc.nextInt();
      int k = sc.nextInt();
      int max = 0;
      if (n%2 == 0) {
          max = n*n/2;
      } else {
          max = (n*n+1)/2;
      }

      if (max < k) {
          out.println("NO");
      } else {
          out.println("YES");
          int count = 1;
          for (int x = 0; x < n; x++) {
              for (int y = 0; y < n; y++) {
                  if (y == n-1) {
                      if ((x+y)%2 == 0 && count <= k) {
                        out.println("L");
                        count++;
                      } else {
                        out.println("S");
                      }
                  } else {
                      if ((x+y)%2 == 0 && count <= k) {
                        out.print("L");
                        count++;
                      } else {
                        out.print("S");
                      }
                  }
              }
          }
      }

      out.close();
      System.exit(0);
  }
}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;

public class Main {
	static BufferedReader in;
	static PrintWriter out;

	public static int getMax(int n) {
		if (n%2==0) return n*n/2;
		else return (n-1)*(n-1)/2 + (n+1)/2 + (n+1)/2 -1;
	}

	public static void main(String[] args) throws IOException {
		in = new BufferedReader(new InputStreamReader(System.in));
		out = new PrintWriter(System.out);

		String[] tok = rst();
		int n = Integer.parseInt(tok[0]);
		int k = Integer.parseInt(tok[1]);

		int max = getMax(n);

		if (k>max) {
			out.println("NO");
		} else {
			out.println("YES");
			int left = k;
			for (int i=0;i<n;i++) {
				for (int j=0;j<n;j++) {
					if ((i+j)%2==0 && left>0) {
						out.print("L");
						left--;
					} else {
						out.print("S");
					}
				}
				out.println();
			}
		}

		in.close();
		out.close();
	}

	public static int ri() throws IOException {
		return Integer.parseInt(in.readLine());
	}

	public static long rl() throws IOException {
		return Long.parseLong(in.readLine());
	}

	public static String rs() throws IOException {
		return in.readLine();
	}

	public static String[] rst() throws IOException {
		return in.readLine().split(" ");
	}

	public static int[] rit() throws IOException {
		String[] tok = in.readLine().split(" ");
		int[] res = new int[tok.length];
		for (int i = 0; i < tok.length; i++) {
			res[i] = Integer.parseInt(tok[i]);
		}
		return res;
	}

	public static long[] rlt() throws IOException {
		String[] tok = in.readLine().split(" ");
		long[] res = new long[tok.length];
		for (int i = 0; i < tok.length; i++) {
			res[i] = Long.parseLong(tok[i]);
		}
		return res;
	}

}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;

public class Main {
	static BufferedReader in;
	static PrintWriter out;

	public static int getMax(int n) {
		if (n%2==0) return n*n/2;
		else return (n-1)*(n-1)/2 + (n+1)/2 + (n+1)/2 -1;
	}

	public static void main(String[] args) throws IOException {
		in = new BufferedReader(new InputStreamReader(System.in));
		out = new PrintWriter(System.out);

		String[] tok = rst();
		int n = Integer.parseInt(tok[0]);
		int k = Integer.parseInt(tok[1]);

		int max = getMax(n);

		if (k>max) {
			out.println("NO");
		} else {
			out.println("YES");
			int left = k;
			for (int i=0;i<n;i++) {
				for (int j=0;j<n;j++) {
					if ((i+j)%2==0 && left>0) {
						out.print("S");
						left--;
					} else {
						out.print("L");
					}
				}
				out.println();
			}
		}

		in.close();
		out.close();
	}

	public static int ri() throws IOException {
		return Integer.parseInt(in.readLine());
	}

	public static long rl() throws IOException {
		return Long.parseLong(in.readLine());
	}

	public static String rs() throws IOException {
		return in.readLine();
	}

	public static String[] rst() throws IOException {
		return in.readLine().split(" ");
	}

	public static int[] rit() throws IOException {
		String[] tok = in.readLine().split(" ");
		int[] res = new int[tok.length];
		for (int i = 0; i < tok.length; i++) {
			res[i] = Integer.parseInt(tok[i]);
		}
		return res;
	}

	public static long[] rlt() throws IOException {
		String[] tok = in.readLine().split(" ");
		long[] res = new long[tok.length];
		for (int i = 0; i < tok.length; i++) {
			res[i] = Long.parseLong(tok[i]);
		}
		return res;
	}

}


import java.io.*;
import java.math.*;
import java.util.*;

public class Main {
    public static void main (String[] args) {
        FastReader in = new FastReader(System.in);

        int n = in.nextInt();
        int k = in.nextInt();

        if (k > n / 2 + n % 2) {
            System.out.println("NO");
            return;
        }

        System.out.println("YES");

        boolean a = true;
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < n; j++) {
                if (a && k > 0) {
                    System.out.print("L");
                    k--;
                } else {
                    System.out.print("S");
                }
                a = !a;
            }
            System.out.println();
        }

    }
}

class FastReader {
    private BufferedReader reader;
    private StringTokenizer tokenizer;

    public FastReader(InputStream stream) {
        this.reader = new BufferedReader(new InputStreamReader(stream));
        this.tokenizer = new StringTokenizer("");
    }

    public boolean hasNext() {
        return ensureTokens();
    }

    public String next() {
        return  ensureTokens() ? tokenizer.nextToken() : null;
    }

    private boolean ensureTokens() {
        while(!tokenizer.hasMoreTokens()){
            try{
                tokenizer = new StringTokenizer(reader.readLine());
            } catch (Exception e){
                return false;
            }
        }
        return true;
    }

    public String nextLine() {
        try {
            return reader.readLine();
        } catch (Exception e) {
            return null;
        }
    }

    public char[] nextCharArray() {
        return nextLine().toCharArray();
    }

    public int nextInt() {
        return Integer.parseInt(next());
    }

    public int[] nextIntArray(int size) {
        int[] array = new int[size];
        for (int i = 0; i < size; i++) {
            array[i] = nextInt();
        }
        return array;
    }

    public int[] nextIntArrayOnLine() {
        String line = nextLine();
        String[] tokens = line.split(" ");
        int[] array = new int[tokens.length];
        for (int i = 0; i < tokens.length; i++) {
            array[i] = Integer.parseInt(tokens[i]);
        }
        return array;
    }

    public long nextLong() {
        return Long.parseLong(next());
    }

    public long[] nextLongArray(int size) {
        long[] array = new long[size];
        for (int i = 0; i < size; i++) {
            array[i] = nextLong();
        }
        return array;
    }

    public float nextFloat() {
        return Float.parseFloat(next());
    }

    public float[] nextFloatArray(int size) {
        float[] array = new float[size];
        for (int i = 0; i < size; i++) {
            array[i] = nextFloat();
        }
        return array;
    }

    public double nextDouble() {
        return Double.parseDouble(next());
    }

    public double[] nextDoubleArray(int size) {
        double[] array = new double[size];
        for (int i = 0; i < size; i++) {
            array[i] = nextDouble();
        }
        return array;
    }

    public short nextShort() {
        return Short.parseShort(next());
    }

    public short[] nextShortArray(int size) {
        short[] array = new short[size];
        for (int i = 0; i < size; i++) {
            array[i] = nextShort();
        }
        return array;
    }

    public BigDecimal nextBigDecimal() {
        return new BigDecimal(next());
    }

    public BigInteger nextBigInteger() {
        return new BigInteger(next());
    }
}

class FastWriter {
    private final PrintWriter printWriter;

    public FastWriter(OutputStream stream) {
        printWriter = new PrintWriter(new BufferedWriter(new OutputStreamWriter(stream)));
    }

    public FastWriter(Writer writer) {
        printWriter = new PrintWriter(writer);
    }

    public void close() {
        printWriter.close();
    }

    public void print(boolean element) {
        printWriter.print(element);
    }

    public void print(char[] element) {
        printWriter.print(element);
    }

    public void print(double element) {
        printWriter.print(element);
    }

    public void print(float element) {
        printWriter.print(element);
    }

    public void print(int element) {
        printWriter.print(element);
    }

    public void print(long element) {
        printWriter.print(element);
    }

    public void print(String element) {
        printWriter.print(element);
    }

    public void print(Object... objects) {
        for (int i = 0; i < objects.length; i++) {
            if (i != 0) {
                printWriter.print(' ');
            }
            printWriter.print(objects[i]);
        }
    }

    public void println(boolean element) {
        printWriter.println(element);
    }

    public void println(char[] element) {
        printWriter.println(element);
    }

    public void println(double element) {
        printWriter.println(element);
    }

    public void println(float element) {
        printWriter.println(element);
    }

    public void println(int element) {
        printWriter.println(element);
    }

    public void println(long element) {
        printWriter.println(element);
    }

    public void println(String element) {
        printWriter.println(element);
    }

    public void println() {
        printWriter.println();
    }

    public void println(Object... objects) {
        print(objects);
        printWriter.println();
    }

    public void printf(String format, Object... args) {
        printWriter.printf(format, args);
    }
}


import java.io.*;
import java.math.*;
import java.util.*;

public class Main {
    public static void main (String[] args) {
        FastReader in = new FastReader(System.in);

        int n = in.nextInt();
        int k = in.nextInt();

        if (k > (n * n) / 2 + (n * n) % 2) {
            System.out.println("NO");
            return;
        }

        System.out.println("YES");

        for (int i = 0; i < n; i++) {
            for (int j = 0; j < n; j++) {
                boolean a = i % 2 == 0 && j % 2 == 0 || i % 2 == 1 && j % 2 == 1;
                if (a && k > 0) {
                    System.out.print("L");
                    k--;
                } else {
                    System.out.print("S");
                }
            }
            System.out.println();
        }

    }
}

class FastReader {
    private BufferedReader reader;
    private StringTokenizer tokenizer;

    public FastReader(InputStream stream) {
        this.reader = new BufferedReader(new InputStreamReader(stream));
        this.tokenizer = new StringTokenizer("");
    }

    public boolean hasNext() {
        return ensureTokens();
    }

    public String next() {
        return  ensureTokens() ? tokenizer.nextToken() : null;
    }

    private boolean ensureTokens() {
        while(!tokenizer.hasMoreTokens()){
            try{
                tokenizer = new StringTokenizer(reader.readLine());
            } catch (Exception e){
                return false;
            }
        }
        return true;
    }

    public String nextLine() {
        try {
            return reader.readLine();
        } catch (Exception e) {
            return null;
        }
    }

    public char[] nextCharArray() {
        return nextLine().toCharArray();
    }

    public int nextInt() {
        return Integer.parseInt(next());
    }

    public int[] nextIntArray(int size) {
        int[] array = new int[size];
        for (int i = 0; i < size; i++) {
            array[i] = nextInt();
        }
        return array;
    }

    public int[] nextIntArrayOnLine() {
        String line = nextLine();
        String[] tokens = line.split(" ");
        int[] array = new int[tokens.length];
        for (int i = 0; i < tokens.length; i++) {
            array[i] = Integer.parseInt(tokens[i]);
        }
        return array;
    }

    public long nextLong() {
        return Long.parseLong(next());
    }

    public long[] nextLongArray(int size) {
        long[] array = new long[size];
        for (int i = 0; i < size; i++) {
            array[i] = nextLong();
        }
        return array;
    }

    public float nextFloat() {
        return Float.parseFloat(next());
    }

    public float[] nextFloatArray(int size) {
        float[] array = new float[size];
        for (int i = 0; i < size; i++) {
            array[i] = nextFloat();
        }
        return array;
    }

    public double nextDouble() {
        return Double.parseDouble(next());
    }

    public double[] nextDoubleArray(int size) {
        double[] array = new double[size];
        for (int i = 0; i < size; i++) {
            array[i] = nextDouble();
        }
        return array;
    }

    public short nextShort() {
        return Short.parseShort(next());
    }

    public short[] nextShortArray(int size) {
        short[] array = new short[size];
        for (int i = 0; i < size; i++) {
            array[i] = nextShort();
        }
        return array;
    }

    public BigDecimal nextBigDecimal() {
        return new BigDecimal(next());
    }

    public BigInteger nextBigInteger() {
        return new BigInteger(next());
    }
}

class FastWriter {
    private final PrintWriter printWriter;

    public FastWriter(OutputStream stream) {
        printWriter = new PrintWriter(new BufferedWriter(new OutputStreamWriter(stream)));
    }

    public FastWriter(Writer writer) {
        printWriter = new PrintWriter(writer);
    }

    public void close() {
        printWriter.close();
    }

    public void print(boolean element) {
        printWriter.print(element);
    }

    public void print(char[] element) {
        printWriter.print(element);
    }

    public void print(double element) {
        printWriter.print(element);
    }

    public void print(float element) {
        printWriter.print(element);
    }

    public void print(int element) {
        printWriter.print(element);
    }

    public void print(long element) {
        printWriter.print(element);
    }

    public void print(String element) {
        printWriter.print(element);
    }

    public void print(Object... objects) {
        for (int i = 0; i < objects.length; i++) {
            if (i != 0) {
                printWriter.print(' ');
            }
            printWriter.print(objects[i]);
        }
    }

    public void println(boolean element) {
        printWriter.println(element);
    }

    public void println(char[] element) {
        printWriter.println(element);
    }

    public void println(double element) {
        printWriter.println(element);
    }

    public void println(float element) {
        printWriter.println(element);
    }

    public void println(int element) {
        printWriter.println(element);
    }

    public void println(long element) {
        printWriter.println(element);
    }

    public void println(String element) {
        printWriter.println(element);
    }

    public void println() {
        printWriter.println();
    }

    public void println(Object... objects) {
        print(objects);
        printWriter.println();
    }

    public void printf(String format, Object... args) {
        printWriter.printf(format, args);
    }
}


import java.util.Scanner;

public class SeaAndIslands {

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        int k = in.nextInt();
        in.close();

        if(k > Math.ceil((n*n)/2.0)) {
            System.out.println("NO");
            return;
        }
        System.out.println("YES");
        int count = 0;
        for(int i=0; i<n; i++) {
            for(int j=0; j<n; j++) {
                if(count < k && ((i%2==0 && j%2==0) || (i%2!=0 && j%2!=0))) {
                    System.out.print("L");
                    count++;
                } else {
                    System.out.print("S");
                }
            }
            System.out.println();
        }

    }

}


import java.util.Scanner;

public class SeaAndIslands {

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        int k = in.nextInt();
        in.close();

        if(k > Math.ceil(n/2.0)) {
            System.out.println("NO");
            return;
        }
        System.out.println("YES");
        int count = 0;
        for(int i=0; i<n; i++) {
            for(int j=0; j<n; j++) {
                if(count < k && ((i%2==0 && j%2==0) || (i%2!=0 && j%2!=0))) {
                    System.out.print("L");
                    count++;
                } else {
                    System.out.print("S");
                }
            }
            System.out.println();
        }

    }

}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class C544B {
    public static int n;
    public static int k;
    public static int[][] map;
    public static boolean answer;

    public static void init() {
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));

        try {
            try {
                String[] items = reader.readLine().split(" ");

                n = Integer.parseInt(items[0]);
                k = Integer.parseInt(items[1]);
            } finally {
                reader.close();
            }
        } catch (IOException ioe) {
            System.out.println(ioe);
        }
    }

    public static void run() {
        int counter = 0;

        map = new int[n][n];
        answer = false;

        stop:
        for (int i = 0; i < map.length; i++) {
            for (int j = 0; j < map[i].length; j++) {

                if (i % 2 == 0 && j % 2 == 0 || i % 2 != 0 && j % 2 != 0) {
                    map[i][j] = 1;

                    if (++counter == k) {
                        answer = true;

                        break stop;
                    }
                }
            }
        }
    }

    public static void print() {
        if (answer) {
            System.out.println("YES");

            for (int i = 0; i < map.length; i++) {
                for (int j = 0; j < map[i].length; j++) {

                    if (map[i][j] == 1) {
                        System.out.print("L");
                    } else {
                        System.out.print("S");
                    }
                }
                System.out.println();
            }
        } else {
            System.out.println("NO");
        }
    }

    public static void main(String[] args) {
        init();
        run();
        print();
    }
}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class C544B {
    public static int n;
    public static int k;
    public static int[][] map;
    public static boolean answer;

    public static void init() {
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));

        try {
            try {
                String[] items = reader.readLine().split(" ");

                n = Integer.parseInt(items[0]);
                k = Integer.parseInt(items[1]);
            } finally {
                reader.close();
            }
        } catch (IOException ioe) {
            System.out.println(ioe);
        }
    }

    public static void run() {
        int counter = 0;

        map = new int[n][n];
        answer = false;

        stop:
        for (int i = 0; i < map.length; i++) {
            for (int j = 0; j < map[i].length; j++) {

                if (i % 2 == 0 && j % 2 == 0 || i % 2 != 0 && j % 2 != 0) {
                    map[i][j] = 1;

                    if (++counter == k || k == 0) {
                        answer = true;

                        break stop;
                    }
                }
            }
        }
    }

    public static void print() {
        if (answer) {
            System.out.println("YES");

            for (int i = 0; i < map.length; i++) {
                for (int j = 0; j < map[i].length; j++) {

                    if (map[i][j] == 1) {
                        System.out.print("L");
                    } else {
                        System.out.print("S");
                    }
                }
                System.out.println();
            }
        } else {
            System.out.println("NO");
        }
    }

    public static void main(String[] args) {
        init();
        run();
        print();
    }
}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class C544B {
    public static int n;
    public static int k;
    public static int[][] map;
    public static boolean answer;

    public static void init() {
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));

        try {
            try {
                String[] items = reader.readLine().split(" ");

                n = Integer.parseInt(items[0]);
                k = Integer.parseInt(items[1]);
            } finally {
                reader.close();
            }
        } catch (IOException ioe) {
            System.out.println(ioe);
        }
    }

    public static void run() {
        int counter = 0;

        map = new int[n][n];
        answer = false;

        stop:
        for (int i = 0; i < map.length; i++) {
            for (int j = 0; j < map[i].length; j++) {

                if (i % 2 == 0 && j % 2 == 0 || i % 2 != 0 && j % 2 != 0) {
                    map[i][j] = 1;

                    if (++counter == k + 1) {
                        answer = true;

                        break stop;
                    }
                }
            }
        }
    }

    public static void print() {
        if (answer) {
            System.out.println("YES");

            for (int i = 0; i < map.length; i++) {
                for (int j = 0; j < map[i].length; j++) {

                    if (map[i][j] == 1) {
                        System.out.print("L");
                    } else {
                        System.out.print("S");
                    }
                }
                System.out.println();
            }
        } else {
            System.out.println("NO");
        }
    }

    public static void main(String[] args) {
        init();
        run();
        print();
    }
}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class C544B {
    public static int n;
    public static int k;
    public static int[][] map;
    public static boolean answer;

    public static void init() {
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));

        try {
            try {
                String[] items = reader.readLine().split(" ");

                n = Integer.parseInt(items[0]);
                k = Integer.parseInt(items[1]);
            } finally {
                reader.close();
            }
        } catch (IOException ioe) {
            System.out.println(ioe);
        }
    }

    public static void run() {
        int counter = 0;

        map = new int[n][n];
        answer = k == 0 ? true : false;

        stop:
        for (int i = 0; i < map.length; i++) {
            for (int j = 0; j < map[i].length; j++) {

                if (i % 2 == 0 && j % 2 == 0 || i % 2 != 0 && j % 2 != 0) {
                    counter += 1;

                    if (counter > k) {
                        break stop;
                    } else if (counter == k) {
                        answer = true;
                    }

                    map[i][j] = 1;
                }
            }
        }
    }

    public static void print() {
        if (answer) {
            System.out.println("YES");

            for (int i = 0; i < map.length; i++) {
                for (int j = 0; j < map[i].length; j++) {

                    if (map[i][j] == 1) {
                        System.out.print("L");
                    } else {
                        System.out.print("S");
                    }
                }
                System.out.println();
            }
        } else {
            System.out.println("NO");
        }
    }

    public static void main(String[] args) {
        init();
        run();
        print();
    }
}


import java.io.BufferedInputStream;
import java.io.PrintStream;
import java.util.Scanner;

public class B {

	private static final Scanner in = new Scanner(new BufferedInputStream(System.in));
	private static final PrintStream out = System.out;

	public static void main(String[] args) {
		int n = in.nextInt();
		int k = in.nextInt();
		if (k > (n*n + 1)/2) {
			out.println("NO");
		} else {
			out.println("YES");
			int cnt = 0;
			for (int i = 0; i < n; ++i) {
				for (int j = 0; j < n; ++j) {
					if (cnt < k && (i + j)%2 == 0) {
						out.print('L');
						++cnt;
					} else
						out.print('S');
				}
				out.println();
			}
		}
	}

}


import java.io.BufferedInputStream;
import java.io.PrintStream;
import java.util.Scanner;

public class B {

	private static final Scanner in = new Scanner(new BufferedInputStream(System.in));
	private static final PrintStream out = System.out;

	public static void main(String[] args) {
		int n = in.nextInt();
		int k = in.nextInt();
		if (k > (n*n + 1)/2) {
			out.println("NO");
		} else {
			out.println("YES");
			int cnt = 0;
			boolean parity = true;
			for (int i = 0; i < n; ++i) {
				for (int j = 0; j < n; ++j) {
					if (cnt < k && parity) {
						out.print('L');
						++cnt;
					} else
						out.print('S');
					parity = !parity;
				}
				out.println();
			}
		}
	}

}


import java.io.IOException;
import java.io.PrintWriter;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.InputMismatchException;
import java.util.Queue;

public class Q1 {

	public static void main(String[] args) {
        FasterScanner s= new FasterScanner();
        PrintWriter out=new PrintWriter(System.out);

        long n=s.nextLong();
        long t=s.nextLong();
        if(t>(n*n+1)/2)
        {
        	out.println("NO");
        	out.close();
        	return;
        }
        out.println("YES");
        for(int i=0;i<n;i++)
        {
        	for(int j=0;j<n;j++)
        	{
        		if(t>0 && (i+j)%2==0)
        		{
        			out.print('L');
        			t--;
        		}
        		else
        			out.print('S');

        	}
        	out.println();
        }

        out.close();
	}

    public static class FasterScanner {
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;

        public int read() {
            if (numChars == -1)
                throw new InputMismatchException();
            if (curChar >= numChars) {
                curChar = 0;
                try {
                    numChars = System.in.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
                if (numChars <= 0)
                    return -1;
            }
            return buf[curChar++];
        }

        public String nextLine() {
            int c = read();
            while (isSpaceChar(c))
                c = read();
            StringBuilder res = new StringBuilder();
            do {
                res.appendCodePoint(c);
                c = read();
            } while (!isEndOfLine(c));
            return res.toString();
        }

        public String nextString() {
            int c = read();
            while (isSpaceChar(c))
                c = read();
            StringBuilder res = new StringBuilder();
            do {
                res.appendCodePoint(c);
                c = read();
            } while (!isSpaceChar(c));
            return res.toString();
        }

        public long nextLong() {
            int c = read();
            while (isSpaceChar(c))
                c = read();
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = read();
            }
            long res = 0;
            do {
                if (c < '0' || c > '9')
                    throw new InputMismatchException();
                res *= 10;
                res += c - '0';
                c = read();
            } while (!isSpaceChar(c));
            return res * sgn;
        }

        public int nextInt() {
            int c = read();
            while (isSpaceChar(c))
                c = read();
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = read();
            }
            int res = 0;
            do {
                if (c < '0' || c > '9')
                    throw new InputMismatchException();
                res *= 10;
                res += c - '0';
                c = read();
            } while (!isSpaceChar(c));
            return res * sgn;
        }

        public int[] nextIntArray(int n) {
            int[] arr = new int[n];
            for (int i = 0; i < n; i++) {
                arr[i] = nextInt();
            }
            return arr;
        }

        public long[] nextLongArray(int n) {
            long[] arr = new long[n];
            for (int i = 0; i < n; i++) {
                arr[i] = nextLong();
            }
            return arr;
        }

        private boolean isSpaceChar(int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        private boolean isEndOfLine(int c) {
            return c == '\n' || c == '\r' || c == -1;
        }
    }
}