#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <stack>
#include <string>
#include <vector>

#define REP(i, n) for(int i = 0; i < n; ++i)
using namespace std;
using LLONG = long long;
const LLONG MOD = 1000000007;

int main()
{
	int N; cin >> N;
	vector<vector<int>> adList(N);
	REP(i, N)
	{
		string S; cin >> S;
		REP(j, N)
		{
			if (S[j] == '1')
			{
				adList[i].push_back(j);
			}
		}
	}
	vector<set<int>> ss(N);
	REP(s, N)
	{
		deque<int> Q{ s };
		vector<bool> arrived(N, false);
		arrived[s] = true;
		while (!Q.empty())
		{
			int t = Q.front(); Q.pop_front();
			ss[t].insert(s);
			for (const int n : adList[t])
			{
				if (arrived[n]) continue;
				Q.push_back(n);
				arrived[n] = true;
			}
		}
	}

	double ans = 0.0;
	REP(s, N)
	{
		const double sv = static_cast<double>(ss[s].size());
		ans += 1.0 / sv;
	}
	cout << setprecision(12) << ans << endl;
}

#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
using ll = long long;
using pii = pair<int, int>;

string dispVec(vector<int> b){
    string ret = to_string(b.size()) + " ";
    rep(i,b.size()) ret += to_string(b[i] + 1) + " ";
    return ret;
}

int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i,n) cin >> a[i];
    int b = min(n,8);
    vector<vector<int>> can(200);
    rep(i,1<<b ){
        if(i==0) continue;
        ll m = 0;
        vector<int> v;
        rep(j,b) if(i >> j & 1) {
            m = m + a[j];
            v.push_back(j);
        }
        if (can[m%200].size() > 0){
            cout << "Yes" << endl;
            cout << dispVec(can[m%200]) << endl;
            cout << dispVec(v) << endl;
            return 0;
        } else {
            can[m%200] = v;
        }        
    }
    cout << "No" << endl;
}