#include<iostream>
#include<algorithm>
#include<vector>
#include<list>
#include<deque>
#include<map>
#include<set>
#include<iterator>
#include<climits>
#include<cmath>

typedef long long int ll;
typedef unsigned long long int ull;

using namespace std;

void solve() {
    int n,m,k,num;
    cin>>n>>m;
    deque<deque<int>> cylinders;
    //creates 2d deque for storing ball numbers present in each cylinder.
    for(int i=0;i<m;i++){
        deque<int> ithCyclinder;
        cin>>k;
        for(int i=0;i<k;i++) {
            cin>>num;
            ithCyclinder.push_back(num);
        }
        cylinders.push_back(ithCyclinder);
    }
    /*
        cout<<"\n----\n";
        for(int i=0;i<cylinders.size();i++) {
            for(int j=0;j<cylinders[i].size();j++) {
                cout<<cylinders[i][j]<<" ";
            }
            cout<<"\n";
        }
    */

    // maps ballNumber to the cylinder numbers if the ballNumber is present at the front of the cylinder. 
    // for example: if ballNumber 1 is present at the front of cylinder numbers 4 and 5, it stores 1->[4,5]
    map<int,vector<int>> mapping; 
    
    // maintains the list of ball numbers with the same color which are present at the front of cylinder in the current iteration.
    deque<int>sameBallsList;
    for(int i=0;i<m;i++){
        //maps the ballNumber present at the front of cylinder i to the cylinder number i. 
        //for example: if 4 is present at the front of 2nd cylinder, it maps 4->[2]
        mapping[cylinders[i][0]].push_back(i);

        //checks if after mapping the current ballNumber to the cylinder i, is the 
        //ballNumber already present at the front of some other cylinder (let's say cylinder j)
        // if it is already present for some cylinder j, it adds the current ballNumber to sameBallsList.
        if(mapping[cylinders[i][0]].size()==2) sameBallsList.push_back(cylinders[i][0]);
    }
    int count=0;

    //if the sameBallsList contains an element, it means we have 2 balls of the same colour at the front of their 
    //respecitve cylinders. so we pop the balls out from the front of the cylinders, and check if there are new
    // pairs of balls in front of the cylinder. if there are, we append the ballNumber to the sameBallsList vector.
    while(sameBallsList.size()){
    /*
        for(int i=0;i<sameBallsList.size();i++) cout<<sameBallsList[i]<<" ";
        cout<<endl;
    */

        //get the ballNumber present at the front of sameBallsList and then pop sameBallsList
        int BallNumber=sameBallsList.front();
        sameBallsList.pop_front();
        
        // get indices of the cylinders at the front of which the current ballNumber is present. for example: if ballNumber 3 is present at the front of the 
        // cylinders 1 and 4, cylinder1=1 and cylinder2=4. then pop both the cylinders.
        int cylinder1= mapping[BallNumber][0];
        int cylinder2= mapping[BallNumber][1];

        cylinders[cylinder1].pop_front();
        cylinders[cylinder2].pop_front();

        //get the balls present at the front of both the cylinders.
        int ball1 = 0,ball2 = 0;
        if(!cylinders[cylinder1].empty())
            ball1= cylinders[cylinder1].front();
        if(!cylinders[cylinder2].empty())
            ball2= cylinders[cylinder2].front();

        //if the ball popped is 0, it means that the cylinder was empty, since from the test case constraints, we
        // can infer that their will be no ball of color 0.
        if(ball1!=0)
            mapping[ball1].push_back(cylinder1);
        if(ball2!=0)
            mapping[ball2].push_back(cylinder2);

        // if both balls are same, we need to append the ballNumber to the sameBallsList just once.
        if (ball1==ball2&&ball1&&ball2) {
            sameBallsList.push_back(ball2);
        }
        else {
            if(ball1&&mapping[ball1].size()==2) sameBallsList.push_back(ball1);
            if(ball2&&mapping[ball2].size()==2) sameBallsList.push_back(ball2);
        }
        count++;
    }
    //cout<<count<<endl;
    //if all the balls are popped, it means there is a way to remove all balls from all cylinders and hence empty all m cylinders.
    if(count==n) cout<<"Yes";
    else cout<<"No";

}

int main() {
    int t=1;
    //cin>>t;
    while(t--){
        solve();
        cout<<"\n";
    }
    return 0;
}