#include <iostream>
#include <functional>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <iomanip>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;++i)
#define repi(i,n) for(ll i=n-1;i>=0;--i)
#define sll(n) scanf("%lld", &n);
#define slf(n) scanf("%lf", &n);
#define pii pair<int, int>
#define pll pair<ll, ll>
typedef long long ll;
typedef double lf;
typedef long long ll;
// const int mod = 1000000007;
const int mod = 998244353;

// vector<string> Qs(max_n);

bool check(vector<pll> ps){
    ll h = 0;
    for(auto p:ps){
        ll b = h + p.first;
        if(b < 0) return false;
        h = h + p.second;
    }

    return true;
}

void Main(){
    ll N;
    string s;
    sll(N);
    vector<pll> ls, rs;
    ll total = 0;
    rep(i, N){
        cin >> s;
        ll h = 0, b = 0;
        for(auto c:s){
            if(c=='(') h++; else h--;
            b = min(b, h);
        }
        if(h>=0) ls.emplace_back(b, h);
        else rs.emplace_back(b-h, -h);
        total += h;
    }
    sort(ls.rbegin(), ls.rend());
    sort(rs.rbegin(), rs.rend());

    if(check(ls) && check(rs) && total == 0){
        printf("Yes\n");
    }else{
        printf("No\n");
    }
    

}

int main(){
    Main();

    return 0;

}
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
using namespace std;
typedef long long ll;
typedef pair<int, int> P;

const ll INF = 1LL << 60;

ll N, K;
vector<ll> v;

int main() {
    cin >> N >> K;
    v.resize(N);
    rep(i, N) cin >> v[i];

    ll ans = 0;
    for (int l = 0; l <= K; l++) {
        for (int r = 0; r <= K - l; r++) {
            if (l + r > N) continue;

            // 戻せる回数
            int d = K - (l + r);

            vector<ll> calc;
            ll tmp = 0;
            // 左からとる

            // cout << "pat1 l " << l << " r: " << r << " " << tmp << endl;
            // [0, l)
            for (int k = 0; k < l; k++) {
                calc.push_back(v[k]);
                tmp += v[k];
            }

            // 右からとる
            // cout << "pat2 l " << l << " r: " << r << " " << tmp << endl;
            // [N - r, N)
            for (int k = 0; k < r; k++) {
                calc.push_back(v[N - 1 - k]);
                tmp += v[N - 1 - k];
            }

            sort(calc.begin(), calc.end());

            // cout << "pat3 l " << l << " r: " << r << " " << tmp << endl;
            // 戻す
            for (int k = 0; k < min(d, (int)calc.size()); k++) {
                if (calc[k] > 0) break;
                tmp -= calc[k];
            }
            // cout << "l " << l << " r: " << r << " " << tmp << endl;
            ans = max(tmp, ans);
        }
    }

    cout << ans << endl;
}