/*#pragma GCC optimize("Ofast,unroll-loops")
#pragma GCC target("avx,avx2,fma")
*/
#include <iostream>
#include <fstream>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <math.h>
#include <set>
#include <map>
#include <string>
#include <tuple>
#include <numeric>
#include <climits>
#include <bitset>
#include <iomanip>
#include <random>
#include <ctime>
using namespace std;
//change the long long to int if you need to save memory/time really badly
typedef long long ll;
typedef long double ld;
const ll MAXN = 2e5 + 5;
const ll INF = 1e14;
const ll MOD = 1e9 + 7;
ll __gcd(ll a, ll b) {
if (b == 0) {
return a;
}
if (a == 0) {
return b;
}
if (a < b) {
swap(a, b);
}
return __gcd(b, a % b);
}
inline ll dig(char c) {
ll ret = c - 'A';
return ret;
}
inline ll compute(ll ind) {
ll ret = 1;
for (ll j = 1; j <= ind; j++) {
ret *= 10;
}
return ret;
}
vector<pair<ll, char>> ans;
bool check(ll val) {
if (val == 0) {
cout << "YES" << endl;
cout << ans.size() << endl;
for (auto el: ans) {
cout << el.first << " " << el.second << endl;
}
return true;
}
return false;
}
void solve(ll ca)
{
ll n, m, k;
cin >> n >> m >> k;
//handle edge cases where one or both dimensions are equal to 1
ll totalnum = 4*n*m - 2*n - 2*m;
if (k > totalnum) {
cout << "NO" << endl;
return;
}
if (n == 1) {
ll tamt = min(m-1, k);
ans.push_back({tamt, 'R'});
k -= tamt;
if (check(k)) {
return;
}
tamt = min(m-1, k);
ans.push_back({tamt, 'L'});
k -= tamt;
if (check(k)) {
return;
}
} else if (m == 1) {
ll tamt = min(n-1, k);
ans.push_back({tamt, 'D'});
k -= tamt;
if (check(k)) {
return;
}
tamt = min(n-1, k);
ans.push_back({tamt, 'U'});
k -= tamt;
if (check(k)) {
return;
}
}
ll col = 0;
while (k > 0 && col < m-1) {
//first go down as much as possible
ll amt = min(k, n-1);
ans.push_back({amt, 'D'});
k -= amt;
if (check(k)) {
return;
}
amt = min(k, n-1);
ans.push_back({amt, 'U'});
k -= amt;
if (check(k)) {
return;
}
ans.push_back({1, 'R'});
k--;
if (check(k)) {
return;
}
col++;
}
if (check(k)) {
return;
}
ans.push_back({1, 'D'});
k--;
if (check(k)) {
return;
}
ll row = 1;
while (k > 0 && row < n) {
//first go down as much as possible
ll amt = min(k, m-1);
ans.push_back({amt, 'L'});
k -= amt;
if (check(k)) {
return;
}
amt = min(k, m-1);
ans.push_back({amt, 'R'});
k -= amt;
if (check(k)) {
return;
}
if (row < n-1) {
ans.push_back({1, 'D'});
k--;
if (check(k)) {
return;
}
}
row++;
}
ll amt = min(k, n-1);
ans.push_back({amt, 'U'});
k -= amt;
if (check(k)) {
return;
}
amt = min(k, m-1);
ans.push_back({amt, 'L'});
k -= amt;
if (check(k)) {
return;
}
return;
}
int main()
{
//mt19937 rng(0);
//Fast IO
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
/*
freopen("sabotage.in", "r", stdin);
freopen("sabotage.out", "w", stdout);
*/
ll t = 1;
//cin >> t;
ll co = 1;
while (t--) {
solve(co);
++co;
}
}
1537A - Arithmetic Array | 1370A - Maximum GCD |
149A - Business trip | 34A - Reconnaissance 2 |
59A - Word | 462B - Appleman and Card Game |
1560C - Infinity Table | 1605C - Dominant Character |
1399A - Remove Smallest | 208A - Dubstep |
1581A - CQXYM Count Permutations | 337A - Puzzles |
495A - Digital Counter | 796A - Buying A House |
67A - Partial Teacher | 116A - Tram |
1472B - Fair Division | 1281C - Cut and Paste |
141A - Amusing Joke | 112A - Petya and Strings |
677A - Vanya and Fence | 1621A - Stable Arrangement of Rooks |
472A - Design Tutorial Learn from Math | 1368A - C+= |
450A - Jzzhu and Children | 546A - Soldier and Bananas |
32B - Borze | 1651B - Prove Him Wrong |
381A - Sereja and Dima | 41A - Translation |