#include <bits/stdc++.h>
using namespace std;
#define ll long long
// #define int long long int
#define ld long double
#define all(x) x.begin(), x.end()
#define sortall(x) sort(all(x))
#define endl '\n'
#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
template<class T>
void printC (T Collection)
{
    for (auto&i:Collection)
        cout << i << " \n";
    cout << '\n';
}

/*
 * Think twice, code once
 * Think of different approaches to tackle a problem: write them down.
 * Think of different views of the problem. don't look from only one side.
 * don't get stuck in one approach.
 * common mistakes: - over_flow
 *                  - out_of_bound index
 *                  - infinite loop
 *                  - corner cases
 *                  - duplication counting.
*/

bool attack(pair<int, int> a, pair<int, int> Q)
{
    for (int i = Q.first-1; i >= 0; --i)
        if (a.first == i && a.second == Q.second)
            return true;
    for (int i = Q.first+1; i < 8; ++i)
        if (a.first == i && a.second == Q.second)
            return true;

    for (int i = Q.second-1; i >= 0; --i)
        if (a.first == Q.first && a.second == i)
            return true;
    for (int i = Q.second+1; i < 8; ++i)
        if (a.first == Q.first && a.second == i)
            return true;

    for (int i = Q.first-1, j = Q.second-1; i >= 0 && j >= 0; --i, --j)
        if (a.first == i && a.second == j)
            return true;
    for (int i = Q.first+1, j = Q.second+1; i < 8 && j < 8; ++i, ++j)
        if (a.first == i && a.second == j)
            return true;

    for (int i = Q.first-1, j = Q.second+1; i >= 0 && j < 8; --i, ++j)
        if (a.first == i && a.second == j)
            return true;
    for (int i = Q.first+1, j = Q.second-1; i < 8 && j >= 0; ++i, --j)
        if (a.first == i && a.second == j)
            return true;
    return false;
}

void solve()
{
    vector<vector<char>> v(8,vector<char>(8));
    set<pair<int, int>> pos;
    for (int i = 0; i < 8; ++i)
    {
        for (int j = 0; j < 8; ++j)
        {
            cin >> v[i][j];
            if (v[i][j] == 'Q')
                pos.insert({i,j});
        }
    }
    for (auto&i:pos)
        for (auto&j:pos)
            if (attack(j, i))
            {
                cout << "invalid";
                return;
            }
    cout << "valid";
}

int32_t main()
{
    // #ifndef ONLINE_JUDGE
    //     freopen("input.txt", "r", stdin);
    //     freopen("output.txt", "w", stdout);
    //     freopen("Errors.txt", "w", stderr);
    // #endif
    fast
    int t = 1;
    // cin >> t;
    while (t--)
    {
        solve();
        if (t) cout << '\n';
    }
    cout << '\n';
    return 0;
}