#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
using namespace std;
const long long oo=1e15;
struct Node
{
	Node *lch,*rch;
	int l,r;
	long long v1,v2,lz;
}*rt;
void update(Node *x)
{
	x->v1=min(x->lch->v1,x->rch->v1);
	x->v2=min(x->lch->v2,x->rch->v2);
}
void add(Node *x,long long v)
{
	x->lz+=v;
	x->v1+=v;
	x->v2+=v;
}
void down(Node *x)
{
	if(x->lz)
	{
		add(x->lch,x->lz);
		add(x->rch,x->lz);
		x->lz=0;
	}
}
int a,b;
Node *Build(int l,int r)
{
	Node *ret=new Node;
	ret->l=l;
	ret->r=r;
	ret->lz=0;
	if(l==r)
	{
		ret->v1=abs(l-a)-l;
		ret->v2=abs(l-a)+l;
		ret->lch=ret->rch=NULL;
		return ret;
	}
	int mid=(l+r)>>1;
	ret->lch=Build(l,mid);
	ret->rch=Build(mid+1,r);
	update(ret);
	return ret;
}
long long query(Node *x,int l,int r,int dir)
{
	if(l<=x->l&&r>=x->r)
	{
		if(dir==1)
			return x->v1;
		else
			return x->v2;
	}
	down(x);
	int mid=(x->l+x->r)>>1;
	long long ret=oo;
	if(l<=mid)
		ret=min(ret,query(x->lch,l,r,dir));
	if(mid<r)
		ret=min(ret,query(x->rch,l,r,dir));
	return ret;
}
void modify(Node *x,int p,long long v)
{
	if(x->l==x->r)
	{
		x->v1=min(x->v1,v-p);
		x->v2=min(x->v2,v+p);
		return ;
	}
	down(x);
	int mid=(x->l+x->r)>>1;
	if(p<=mid)
		modify(x->lch,p,v);
	else
		modify(x->rch,p,v);
	update(x);
}
long long findans(Node *x)
{
	if(x->l==x->r)
		return x->v1+x->l;
	down(x);
	return min(findans(x->lch),findans(x->rch)); 
} 
int main()
{
	int n,q,la,x;
	long long mi;
	scanf("%d%d%d%d",&n,&q,&a,&b);
	la=b;
	rt=Build(1,n);
	for(int i=1;i<=q;i++)
	{
		scanf("%d",&x);
		mi=min(query(rt,1,x,1)+x,query(rt,x,n,2)-x);
		add(rt,abs(x-la));
		modify(rt,la,mi);
		la=x;
	}
	printf("%lld",findans(rt));
	return 0;
}
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 
#include <ext/pb_ds/detail/standard_policies.hpp>
using namespace __gnu_pbds;
using namespace std;
#define getbit(n, i) (((n) & (1LL << (i))) != 0) 
#define setbit0(n, i) ((n) & (~(1LL << (i)))) 
#define setbit1(n, i) ((n) | (1LL << (i))) 
#define togglebit(n, i) ((n) ^ (1LL << (i))) 
#define lastone(n) ((n) & (-(n))) 
char gap = 32;
template<typename T> 
ostream& operator<<(ostream &os, const vector<T> &v) { 
    os << '{'; 
    for (const auto &x : v) os << gap << x;
        return os << '}'; 
}
template<typename A, typename B> 
ostream& operator<<(ostream &os, const pair<A, B> &p) {
        return os << '(' << p.first << gap << p.second << ')';
}

template <class T>
void read(T &x) {
    char c;
    for (c = getchar(); c < '0' || c > '9'; c = getchar())
        ;
    for (x = 0; c <= '9' && c >= '0'; c = getchar()) x = x * 10 + (c & 15);
}
#define ll long long 
#define lll __int128_t
#define pb push_back
#define mp make_pair
typedef pair < int,int> ii;
typedef vector<ii> vii;
typedef vector<ll>vl;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef tree<
int,
null_type,
less<int>,
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
ll hashPrime = 1610612741;
ll count1(string s){
    ll mini = 0;
    ll cnt = 0;
    ll sz = s.size();
    for (ll i = 0; i < sz;i++){
        if(s[i]==')')
            cnt--;
        else
        {
            cnt++;
        }
        mini = min(mini, cnt);
    }
    return abs(mini);
}
ll count2(string s){
    ll mini = 0;
    ll cnt = 0;
    ll sz = s.size();
    for (ll i = sz - 1; i >= 0; i--)
    {
        if(s[i]=='(')
            cnt--;
        else
        {
            cnt++;
        }
        mini = min(mini, cnt);
    }
    return abs(mini);
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    ll i, j, k, l, n, m;
    cin >> n;
    vector<pair<ll, ll>> type1, type2, type3;
    ll bal = 0;
    ll bal1 = 0;
    for (i = 1; i <= n;i++){
        string s;
        cin >> s;
        for(auto x:s){
            if(x=='(')
                bal++;
            else
            {
                bal--;
            }
        }
        ll cnt1 = count1(s);
        bal1 += cnt1;
        ll cnt2 = count2(s);
        bal1 -= cnt2;
        if(cnt1+cnt2==0)
            continue;
        if(cnt2-cnt1>=0){
            type1.pb({cnt1, cnt2});
        }
        else{
            type2.pb({cnt2, cnt1});
        }
    }
    sort(type1.begin(), type1.end());
    sort(type2.begin(), type2.end());
    if (bal!=0||bal1!=0){
        cout << "No\n";
        return 0;
    }
    ll prev = 0;
    ll sz1 = type1.size();
    ll sz2 = type2.size();
    for (i = 0; i < sz1;i++){
        if(type1[i].first>prev){
            cout << "No\n";
            return 0;
        }
        else{
            prev -= type1[i].first;
            prev += type1[i].second;
        }
    }
    for (i = sz2-1; i >=0;i--){
        if(type2[i].second>prev){
            cout << "No\n";
            return 0;
        }
        else{
            prev += type2[i].first;
            prev -= type2[i].second;
        }
    }
    cout << "Yes\n";
    return 0;
}