#include <iostream>
#include <fstream>
#include <algorithm>
#include <functional>
#include <array>
#include <chrono>
#include <random>
#include <vector>
#include <string>
#include <cmath>
#include <bitset>
#include <list>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cassert>

#define sq(x) ((x) * (x))
#define err(x) cerr << "["#x"]  " << (x) << "\n";
#define errp(x) cerr << "["#x"]  {" << ((x).first) << ", " << ((x).second) << "}\n";
#define errv(x) {cerr << "["#x"]  [";for(const auto& ___ : (x)) cerr << ___ << ", "; cerr << "]\n";}
#define errvn(x, n) {cerr << "["#x"]  [";for(auto ___ = 0; ___ < (n); ++___) cerr << (x)[___] << ", "; cerr << "]\n";}
#define errf() cerr << "\n\n";

#pragma GCC optimize("Ofast")

using namespace std;

using ll = long long;
using ull = unsigned long long;
using ld = long double;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
ll getrnd(ll l, ll r) {
    return uniform_int_distribution<ll>(l, r)(rng);
}

template <typename T1, typename T2> inline bool relax(T1& a, const T2& b) {
    return a > b ? a = b, true : false;
}

template <typename T1, typename T2> inline bool strain(T1& a, const T2& b) {
    return a < b ? a = b, true : false;
}

// :::::::::::::::::::::::::::::::

const int N = 103;

int cnt[N], was[N];

void dfs(int v, vector<string>& graph) {
    if (was[v]) return;
    
    was[v] = 1;
    ++cnt[v];
    for (int i = 0; i < graph[v].size(); ++i) {
        if (graph[v][i] == '1')
            dfs(i, graph);
    }
}

void solve() {
    int n;
    cin >> n;
    
    vector<string> graph(n);
    for (int i = 0; i < n; ++i)
        cin >> graph[i];
    
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < n; ++j)
            was[j] = 0;
        dfs(i, graph);
    }
    
    ld ans = 0;
    for (int i = 0; i < n; ++i)
        ans += (ld) 1 / cnt[i];
    cout.precision(10);
    cout << fixed << ans << '\n';
}

int main() {
    ios::sync_with_stdio(0);
    cin.tie(nullptr); cout.tie(nullptr);
    srand(time(0));
    
    int t = 1;
//    cin >> t;
    while (t--)
        solve();
    
    return 0;
}

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
const ll MOD = 1000000007;
const ll INF = 0x3fffffff;
#define lln          \
	long long n = 0; \
	cin >> n
#define rep(i, n) for (ll i = 0; i < n; i++)
#define sVec(vec) sort(vec.begin(), vec.end())
#define rVec(vec) reverse(vec.begin(), vec.end())
#define iVec(vec)                       \
	for (ll i = 0; i < vec.size(); i++) \
	{                                   \
		cin >> vec.at(i);               \
	}
#define oVec(vec)                       \
	for (ll i = 0; i < vec.size(); i++) \
	{                                   \
		cout << vec.at(i) << endl;      \
	}
#define ExactMinority(degits) \
	cout << fixed << setprecision(degits)
#define UniqueVector(vec)         \
	sort(vec.begin(), vec.end()); \
	vec.erase(unique(vec.begin(), vec.end()), vec.end())

int main()
{
	string s;
	cin >> s;
	string t;
	bool a = false;
	for (int i = 0; i < s.size(); i++)
	{
		if (s[i] == 'R')
		{
			a = !a;
		}
		else
		{
			if (a)
			{
				t.insert(t.begin(), s[i]);
			}
			else
			{
				t += s[i];
			}
		}
	}
	if (a)
	{
		reverse(t.begin(), t.end());
	}
	if (t.empty())
	{
		cout << endl;
		return 0;
	} 
	for (int i = 0; i < t.size() - 1; i++)
	{
	a:
		if (t[i] == t[i + 1])
		{
			t.erase(i, 2);
			if (t.empty())
			{
				cout << endl;
				return 0;
			}
			if (i > 0)
			{
				i --;
			}
			goto a;
		}
	}
	cout << t << endl;
}