******************************* *** The hack uses generator *** ******************************* ** Command line arguments ** no arguments ** Generated test ** 200000 UL UL UL UL UL UL UL UL UL UL UL UL UL UL UL UL UL UL UL UL UL UL UL UL UL UL UL UL UL UL UL UL UL UL UL UL UL UL UL UL UL UL UL UL UL UL UL UL UL UL UL UL UL UL UL UL UL UL UL UL UL UL ... ** Generator source ** #pragma comment(linker, "/STACK:60000000") //#define _MY_OPT_MODE_ #define _CRT_SECURE_NO_WARNINGS #define _CRT_SECURE_NO_DEPRECATE #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; typedef long double ldb; typedef long long int64; typedef pair pii; typedef pair pdd; #define y0 wwwwwww #define y1 qqqqqqq #define next NEXT #define prev PREV #define forn(i, n) for (int i = 0; i < (int) n; i++) #define ford(i, n) for (int i = (int) n - 1; i >= 0; i--) #define seta(a, b) memset(a, b, sizeof(a)) #define pb push_back #define all(a) (a).begin(), (a).end() #define last(a) a[a.size() - 1] #define mp make_pair #define fs first #define sc second template T sqr(T x) { return x * x; } double const pi = 3.1415926535897932384626433832795; int const inf = (int) 1e9; int64 const inf64 = (int64) 4e18; const string name = "c"; const int NMAX = 100100; int ans, n, m, used[NMAX], h[NMAX], close[NMAX]; vector g[NMAX]; int gcd(int a, int b) { if (a > b) swap(a, b); if (a == 0) return b; else return gcd(b % a, a); } void dfs(int v, int hh) { used[v] = 1; h[v] = hh; forn(i, g[v].size()) if (!used[g[v][i]]) dfs(g[v][i], hh + 1); else if (!close[g[v][i]]) { int now = hh - h[g[v][i]] + 1; if (ans == -1) ans = now; else ans = gcd(ans, now); } close[v] = 1; } int main() { #ifndef ONLINE_JUDGE //freopen((name + ".in").data(), "r", stdin); //freopen((name + ".out").data(), "w", stdout); #endif cout << 200000 << endl; forn(i, 199998) printf("UL\n"); cout << "UR" << endl; cout << "ULDR" << endl; return 0; cin >> n >> m; forn(i, m) { int x, y; scanf("%d%d", &x, &y); x--, y--; g[x].pb(y); } ans = -1; seta(used, 0); seta(close, 0); forn(i, n) if (!used[i]) dfs(i, 0); if (ans == -1) cout << n << endl; else cout << ans << endl; return 0; }