#include <bits/stdc++.h>

using namespace std;

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    bool bad = false;
    int n, m;
    cin >> n >> m;
    vector< vector<bool> > a(n, vector<bool>(m, false));
    vector<int> r(n, 0), c(m, 0);
    set< pair<int, int> > q;
    for (int i = 0; i < n; i++) {
        cin.ignore();
        for (int j = 0; j < m; j++) {
            char c;
            cin.get(c);
            if (c == '#') {
                a[i][j] = true;
                q.insert({i, j});
            }
        }
    }

    queue<int> rq, cq;
    vector<int> rr;
    rr.reserve(n);
    while (!q.empty() && !bad) {
        rq.push(q.begin()->first);
        cq.push(q.begin()->second);
        if (r[q.begin()->first] != 0)
            bad = true;
        if (c[q.begin()->second] != 0)
            bad = true;

        r[q.begin()->first] = 1;
        c[q.begin()->second] = 1;

        q.erase(q.begin());
        while (!rq.empty() || !cq.empty()) {
            if (!rq.empty()) {
                int cur = rq.front();
                rq.pop();
                for (int i = 0; i < m; i++) {
                    if (a[cur][i]) {
                        if (c[i] == 2)
                            bad = true;
                        if (c[i] == 0) {
                            cq.push(i);
                            c[i] = 1;
                        }
                        q.erase({cur, i});
                    }
                }
            }

            if (!cq.empty()) {
                int curc = cq.front();
                cq.pop();
                for (int i = 0; i < n; i++) {
                    if (a[i][curc]) {
                        if (r[i] == 2)
                            bad = true;
                        if (r[i] == 0) {
                            rq.push(i);
                            r[i] = 1;
                        }
                        q.erase({i, curc});
                    }
                }
            }
        }

        for (int i = 0; i < n; i++) {
            if (r[i] == 1) {
                r[i] = 2;
                rr.push_back(i);
            }
        }
        for (int i = 0; i < m; i++) {
            if (c[i] == 1) {
                c[i] = 2;
                for (int j = 0; j < rr.size(); j++) {
                    if (!a[rr[j]][i])
                        bad = true;
                }
            }
        }
        rr.clear();

    }

    if (bad)
        cout << "No";
    else
        cout << "Yes";

    return 0;
}


#define FAST ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#include <iostream>
#include <algorithm>

using namespace std;

char c[50][50];
unsigned short int m;

bool eq(const unsigned short int a,const unsigned short int b){
	for(unsigned short int k=0;k<m;k++){
		if(c[a][k]!=c[b][k]){
			return false;
		}
	}
	return true;
}

bool ex(const unsigned short int a, const unsigned short int b){
	for(unsigned short int i=0;i<m;i++){
		if(c[a][i]=='#'&&c[b][i]=='#'){
			return false;
		}
	}
	return true;
}

int main(){
	unsigned short int n;
	cin >> n >> m;
	for(unsigned short int i=0;i<n;i++){
		for(unsigned short int j=0;j<m;j++){
			cin >> c[i][j];
		}
	}
	bool inc[n];
	fill_n(inc,n,false);
	for(unsigned short int i=0;i<n-1;i++){
		if(!inc[i]){
			for(unsigned short int j=i+1;j<n;j++){
				if(eq(i,j)){
					inc[j] = true;
				}
			}
			for(unsigned short int j=i+1;j<n;j++){
				if(!inc[j] && !ex(i,j)){
					cout << "No" << endl;
					return 0;
				}
			}
		}
	}
	cout << "Yes" << endl;
}


 //code by thesixpathguy

 //libraries
 #include<bits/stdc++.h>
 #include<ext/pb_ds/assoc_container.hpp>
 #include <ext/pb_ds/tree_policy.hpp>

 //namespaces
 using namespace std;
 using namespace __gnu_pbds;

 //template
 #define lint                     long long
 #define setbits(x)              __builtin_popcountll(x)
 #define zrbits(x)               __builtin_ctzll(x)
 #define zlbits(x)               __builtin_clzll(x)
 #define parsbits(x)             __builtin_parityll(x)
 #define mem(a, b)               memset(a, (b), sizeof(a))
 #define MOD                     1000000007
 #define inf                     1e17
 #define neginf                  -1e17
 #define sp(x,y)                 fixed<<setprecision(x)<<y
 #define testcase(t)             lint t; cin>>t; while(t--)
 #define power(a,b)              (double)pow((double)a,(double)b)
 #define high(a,b)               ceil((double)a/(double)b)
 #define low(a,b)                floor((double)a/(double)b)
 #define FOR(i,n)                for(lint i=0;i<n;i++)
 #define gcd(a,b)                __gcd(a,b)
 #define PI                      3.1415926535
 #define pb                      push_back
 #define ss                      second
 #define ff                      first
 #define umap                    unordered_map
 #define ummap                   unordered_multimap
 #define uset                    unordered_set
 #define umset                   unordered_multiset

 typedef unsigned long long   ull;

 typedef tree<int,null_type,less<int>,rb_tree_tag,
 tree_order_statistics_node_update> indexed_set;

 //debug statements start (does not debug array)
 void __print(int x) {cerr << x;}
 void __print(long x) {cerr << x;}
 void __print(long long x) {cerr << x;}
 void __print(unsigned x) {cerr << x;}
 void __print(unsigned long x) {cerr << x;}
 void __print(unsigned long long x) {cerr << x;}
 void __print(float x) {cerr << x;}
 void __print(double x) {cerr << x;}
 void __print(long double x) {cerr << x;}
 void __print(char x) {cerr << '\'' << x << '\'';}
 void __print(const char *x) {cerr << '\"' << x << '\"';}
 void __print(const string &x) {cerr << '\"' << x << '\"';}
 void __print(bool x) {cerr << (x ? "true" : "false");}

 template<typename T, typename V>
 void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
 template<typename T>
 void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
 void _print() {cerr << "]\n";}
 template <typename T, typename... V>
 void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
 #ifndef ONLINE_JUDGE
 #define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
 #else
 #define debug(x...)
 #endif
 //debug statements end

 //fast input output and file handling
 void c_p_c()
 {
     ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
     #ifndef ONLINE_JUDGE
     freopen("C:\\Users\\pranjal bhatt\\Desktop\\code contests\\input1cc.txt", "r", stdin);
     freopen("C:\\Users\\pranjal bhatt\\Desktop\\code contests\\output1cc.txt", "w", stdout);
     #endif
 }

 //useful functions
 lint me(lint x, lint y, lint p)
 {
     lint res=1;
     x=x%p;
     if(x==0)return 0;
     while(y > 0)
     {
         if (y & 1)
         res = (res*x) % p;
         y = y>>1;
         x = (x*x) % p;
     }
     return res;
 }

     /*---------------------------SOLUTION---------------------------------*/

 //solve function
 void solve()
 {
     ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
     lint n,m;
     cin>>n>>m;
     vector<string> v(n);
     for(lint i=0;i<n;i++)
     {
        cin>>v[i];
     }
     for(lint i=0;i<n;i++)
     {
        for(lint j=i+1;j<n;j++)
        {
            lint c=0;
            lint d=0;
            lint e=0;
            for(lint k=0;k<m;k++)
            {
                if(v[i][k]==v[j][k]&&v[i][k]=='#')
                    c++;
                if(v[i][k]=='#')
                    d++;
                if(v[j][k]=='#')
                    e++;
            }
            if(c>0)
            {
                if(c!=d||c!=e)
                {
                    cout<<"NO\n";
                    return;
                }
            }
        }
     }
     cout<<"YES\n";
 }

 //main function
 int main()
 {
     c_p_c();
     lint flg99=0;
     if(flg99==1)
     {
         testcase(t)
         {
              solve();
         }
     }
     else
     {
         solve();
     }
     return 0;

 }


#include <iostream>
#include <string>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <functional>
#include <stack>
#include <queue>
#include <climits>
#define endl '\n'
#define ll long long

using namespace std;

int main(void)
{
    cin.tie(NULL); ios_base::sync_with_stdio(false);
    int n, m; cin >> n >> m;
    vector<string> vec;
    for(int i = 0; i < n; i++)
    {
        string temp; cin >> temp; vec.push_back(temp);
    }

    string empty = ""; for(int i = 0; i < m; i++) empty += '.';
    for(int i = 0; i < n; i++)
    {
        for(int j = i + 1; j < n; j++)
        {
            if(vec[i] == vec[j])
                vec[j] = empty;
        }
    }

    auto col_visited = new bool[m]();

    for(int i = 0; i < n; i++)
    {
        for(int j = 0; j < m; j++)
        {
            if(vec[i][j] != '#') continue;

            if(col_visited[j]) { cout << "No" << endl; return 0; }
            col_visited[j] = true;
        }
    }
    cout << "Yes" << endl;
    return 0;
}


/*
Author: Ayush Agrawal, IIT Ropar
*/
#include <iostream>
//#include <bits/stdc++.h>
#include <cstdio>
#include <list>
#include <vector>
#include <stack>
#include <deque>
#include <cstring>
#include <limits.h>
#include <set>
#include <cmath>
#include <algorithm>
#include <string>
#include <map>
#include <unordered_map>
#include <utility>
#define all(x) (x).begin(), (x).end()
#define ull unsigned long long int
#define ll long long int
#define ld long double
#define pb push_back
#define ep emplace_back
#define mp make_pair
#define pcc pair<char,char>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pq priority_queue <ll>
#define ppq priority_queue <pll>
#define vi vector <int>
#define vb vector <bool>
#define vl vector <ll>
#define vpl vector <pll>
#define vc vector <char>
#define mmi multimap<int,int>
#define mml multimap<ll,ll>
#define mmc multimap<char,char>
#define mi map<int,int>
#define ml map<ll,ll>
#define mc map<char,char>
#define clr(a) memset(a,-1,sizeof(a))
#define mod 1000000007
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL)
#define endl "\n"
#define INF 1e+18
using namespace std;
bool primecheck(ll a)
{
    bool check  = true;

    if(a==1)
        return(false);

    for(ll i=2;i<=sqrt(a);i++)
    {
        if(a%i==0){
            check = false;
            break;
        }
    }

    return(check);
}
vl primeFactors(ll n)
{
    // Print the number of 2s that divide n
    vl sol;
    bool once = false;
    while (n % 2 == 0)
    {
        // cout << 2 << " ";
        if(!once)
        {
            sol.pb(2);
            once = true;
        }
        n = n/2;
    }

    // n must be odd at this point. So we can skip
    // one element (Note i = i +2)
    for (int i = 3; i <= sqrt(n); i = i + 2)
    {
        // While i divides n, print i and divide n
        bool once = false;
        while (n % i == 0)
        {
            // cout << i << " ";
            if(!once)
            {
                sol.pb(i);
                once = true;
            }
            n = n/i;
        }
    }

    // This condition is to handle the case when n
    // is a prime number greater than 2
    if (n > 2)
        {
            sol.pb(n);
        }
    return(sol);
}
vl printDivisors(ll n)
{
    // Note that this loop runs till square root
    vl sol;
    for (ll i=1; i<=sqrt(n); i++)
    {
        if (n%i == 0)
        {
            // If divisors are equal, print only one
            if (n/i == i){
                //printf("%d ", i);
               sol.pb(i);
                 }

            else {
                sol.pb(i);
                sol.pb(n/i);
            }// Otherwise print both
                //printf("%d %d ", i, n/i);
        }
    }
    return(sol);
}
ll digits(ll a)
{
    return(floor(log10(a))+1);
}
ll bits(ll n)
{
    return __builtin_popcount(n);
}
long long binpow(long long a, long long b, long long m) {
    a %= m;
    long long res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a % m;
        a = a * a % m;
        b >>= 1;
    }
    return res;
}
ll modInverse(ll a, ll m)
{
    ll m0 = m;
    ll y = 0, x = 1;

    if (m == 1)
      return 0;

    while (a > 1)
    {
        // q is quotient
        ll q = a / m;
        ll t = m;

        // m is remainder now, process same as
        // Euclid's algo
        m = a % m, a = t;
        t = y;

        // Update y and x
        y = x - q * y;
        x = t;
    }

    // Make x
    if (x < 0)
       x += m0;

    return x;
}
// ll nCr(ll n,ll r)
// {
//     // fact needs to be pre-calculated
//     ll val1 = fact[n];
//     ll val2 = fact[n-r]*fact[r];
//     val2 = modInverse(val2,mod);
//     val1%=mod;
//     val2%=mod;
//     //cout<<val1<<" "<<val2<<endl;
//     return(val1*val2);
// }
int gcd(int a, int b)
{
    // Everything divides 0
    if (a == 0)
       return b;
    if (b == 0)
       return a;

    // base case
    if (a == b)
        return a;

    // a is greater
    if (a > b)
        return gcd(a-b, b);
    return gcd(a, b-a);
}
ll lcm(ll a, ll b)
 {
    return (a*b)/gcd(a, b);
 }
 void addEdge(vl adj[],ll u, ll v)
 {
    adj[u].pb(v);
    adj[v].pb(u);
 }
 vl path;
 void dfs(ll u, vl adj[], vb &visited, ll parent = -1)
 {
    visited[u] = true;
    path[u] = parent;
    // count<<u<<endl;
    for(ll i=0;i<adj[u].size();i++)
    {
        if(visited[adj[u][i]]==false)
        {
            dfs(adj[u][i],adj,visited,u);
        }
    }
 }
 /*
__builtin_clz(x): This function is used to count the leading zeros of the integer. Note : clz = count leading zero’s
__builtin_ctz(x): This function is used to count the trailing zeros of the given integer. Note : ctz = count trailing zeros.
unique(all(vec)); will remove all duplicate elements from the vector
find_by_order() - Returns an iterator to the k-th largest element (counting from zero)
order_of_key()  - The number of items in a set that are strictly smaller than our item
*max_element (first_iterator, last_iterator) – To find the maximum element of a vector.
*min_element (first_iterator, last_iterator) – To find the minimum element of a vector.
accumulate(first_iterator, last_iterator, initial value of sum) – Does the summation of vector elements
count(first_iterator, last_iterator,x) – To count the occurrences of x in vector.
find(first_iterator, last_iterator, x) – Points to last address of vector ((name_of_vector).end()) if element is not present in vector.
binary_search(first_iterator, last_iterator, x) – Tests whether x exists in sorted vector or not.
lower_bound(first_iterator, last_iterator, x) – returns an iterator pointing to the first element in the range [first,last) which has a value not less than ‘x’.
upper_bound(first_iterator, last_iterator, x) – returns an iterator pointing to the first element in the range [first,last) which has a value greater than ‘x’.
arr.erase(position to be deleted) – This erases selected element in vector and shifts and resizes the vector elements accordingly.
arr.erase(unique(arr.begin(),arr.end()),arr.end()) – This erases the duplicate occurrences in sorted vector in a single line.
next_permutation(first_iterator, last_iterator) – This modified the vector to its next permutation.
prev_permutation(first_iterator, last_iterator) – This modified the vector to its previous permutation.
 */

 char graph[50][50];
 bool visited[50][50];
deque<pll> que;
 vl row;
 vl cols;

 void move(ll a,ll b)
 {
   ll i,j,k,l;
    while(!que.empty())
    {
        pll top = que.front();
        que.pop_front();

        row[top.first]++;
        cols[top.second]++;

        // cout<<top.first<<" "<<top.second<<endl;

        // graph[top.first][top.second] = '.';

        for(i=0;i<a;i++)
        {
           if(graph[i][top.second]=='#' && visited[i][top.second]==false)
           {
            visited[i][top.second] = true;
            que.pb(mp(i,top.second));

           }
        }

        for(i=0;i<b;i++)
        {
           if(graph[top.first][i]=='#' && visited[top.first][i]==false)
           {
            visited[top.first][i] = true;
            que.pb(mp(top.first,i));

           }
        }
    }
 }

int main()
{
    fastio;

    ll a,b,c,i,j,k,l,m,n,t,p;

    cin>>a>>b;

    for(i=0;i<a;i++)
    {
        for(j=0;j<b;j++)
        {
            cin>>graph[i][j];
            visited[i][j] = false;
        }
    }

    vl row_fin(a,0);
    vl cols_fin(b,0);

    bool possible = true;

    for(i=0;i<a;i++)
    {
        for(j=0;j<b;j++)
        {
            if(graph[i][j]=='#')
            {
                row.clear();
                que.clear();
                cols.clear();
                for(k=0;k<50;k++){
                    row.pb(0);
                    cols.pb(0);
                }
                // row[i]++;
                // cols[j]++;

                que.pb(mp(i,j));

                move(a,b);

                for(m=0;m<a;m++)
                {
                    for(n=0;n<b;n++)
                    {
                        if(row[m] && cols[n])
                        {
                            if(graph[m][n]=='.')
                                possible = false;
                            else
                                graph[m][n] = '.';
                        }
                    }
                }

                for(i=0;i<a;i++)
                {
                    if(row[i]){
                        row_fin[i]++;
                        if(row_fin[i]>1)
                            possible =false;
                    }
                }

                for(i=0;i<b;i++)
                {
                    if(cols[i]){
                        cols_fin[i]++;
                        if(cols_fin[i]>1)
                            possible = false;
                    }
                }
            }
        }
    }

    if(possible)
        cout<<"Yes"<<endl;
    else
    {
        cout<<"No"<<endl;
    }

}


/*
Author: Ayush Agrawal, IIT Ropar
*/
#include <iostream>
//#include <bits/stdc++.h>
#include <cstdio>
#include <list>
#include <vector>
#include <stack>
#include <deque>
#include <cstring>
#include <limits.h>
#include <set>
#include <cmath>
#include <algorithm>
#include <string>
#include <map>
#include <unordered_map>
#include <utility>
#define all(x) (x).begin(), (x).end()
#define ull unsigned long long int
#define ll long long int
#define ld long double
#define pb push_back
#define ep emplace_back
#define mp make_pair
#define pcc pair<char,char>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pq priority_queue <ll>
#define ppq priority_queue <pll>
#define vi vector <int>
#define vb vector <bool>
#define vl vector <ll>
#define vpl vector <pll>
#define vc vector <char>
#define mmi multimap<int,int>
#define mml multimap<ll,ll>
#define mmc multimap<char,char>
#define mi map<int,int>
#define ml map<ll,ll>
#define mc map<char,char>
#define clr(a) memset(a,-1,sizeof(a))
#define mod 1000000007
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL)
#define endl "\n"
#define INF 1e+18
using namespace std;
bool primecheck(ll a)
{
    bool check  = true;

    if(a==1)
        return(false);

    for(ll i=2;i<=sqrt(a);i++)
    {
        if(a%i==0){
            check = false;
            break;
        }
    }

    return(check);
}
vl primeFactors(ll n)
{
    // Print the number of 2s that divide n
    vl sol;
    bool once = false;
    while (n % 2 == 0)
    {
        // cout << 2 << " ";
        if(!once)
        {
            sol.pb(2);
            once = true;
        }
        n = n/2;
    }

    // n must be odd at this point. So we can skip
    // one element (Note i = i +2)
    for (int i = 3; i <= sqrt(n); i = i + 2)
    {
        // While i divides n, print i and divide n
        bool once = false;
        while (n % i == 0)
        {
            // cout << i << " ";
            if(!once)
            {
                sol.pb(i);
                once = true;
            }
            n = n/i;
        }
    }

    // This condition is to handle the case when n
    // is a prime number greater than 2
    if (n > 2)
        {
            sol.pb(n);
        }
    return(sol);
}
vl printDivisors(ll n)
{
    // Note that this loop runs till square root
    vl sol;
    for (ll i=1; i<=sqrt(n); i++)
    {
        if (n%i == 0)
        {
            // If divisors are equal, print only one
            if (n/i == i){
                //printf("%d ", i);
               sol.pb(i);
                 }

            else {
                sol.pb(i);
                sol.pb(n/i);
            }// Otherwise print both
                //printf("%d %d ", i, n/i);
        }
    }
    return(sol);
}
ll digits(ll a)
{
    return(floor(log10(a))+1);
}
ll bits(ll n)
{
    return __builtin_popcount(n);
}
long long binpow(long long a, long long b, long long m) {
    a %= m;
    long long res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a % m;
        a = a * a % m;
        b >>= 1;
    }
    return res;
}
ll modInverse(ll a, ll m)
{
    ll m0 = m;
    ll y = 0, x = 1;

    if (m == 1)
      return 0;

    while (a > 1)
    {
        // q is quotient
        ll q = a / m;
        ll t = m;

        // m is remainder now, process same as
        // Euclid's algo
        m = a % m, a = t;
        t = y;

        // Update y and x
        y = x - q * y;
        x = t;
    }

    // Make x
    if (x < 0)
       x += m0;

    return x;
}
// ll nCr(ll n,ll r)
// {
//     // fact needs to be pre-calculated
//     ll val1 = fact[n];
//     ll val2 = fact[n-r]*fact[r];
//     val2 = modInverse(val2,mod);
//     val1%=mod;
//     val2%=mod;
//     //cout<<val1<<" "<<val2<<endl;
//     return(val1*val2);
// }
int gcd(int a, int b)
{
    // Everything divides 0
    if (a == 0)
       return b;
    if (b == 0)
       return a;

    // base case
    if (a == b)
        return a;

    // a is greater
    if (a > b)
        return gcd(a-b, b);
    return gcd(a, b-a);
}
ll lcm(ll a, ll b)
 {
    return (a*b)/gcd(a, b);
 }
 void addEdge(vl adj[],ll u, ll v)
 {
    adj[u].pb(v);
    adj[v].pb(u);
 }
 vl path;
 void dfs(ll u, vl adj[], vb &visited, ll parent = -1)
 {
    visited[u] = true;
    path[u] = parent;
    // count<<u<<endl;
    for(ll i=0;i<adj[u].size();i++)
    {
        if(visited[adj[u][i]]==false)
        {
            dfs(adj[u][i],adj,visited,u);
        }
    }
 }
 /*
__builtin_clz(x): This function is used to count the leading zeros of the integer. Note : clz = count leading zero’s
__builtin_ctz(x): This function is used to count the trailing zeros of the given integer. Note : ctz = count trailing zeros.
unique(all(vec)); will remove all duplicate elements from the vector
find_by_order() - Returns an iterator to the k-th largest element (counting from zero)
order_of_key()  - The number of items in a set that are strictly smaller than our item
*max_element (first_iterator, last_iterator) – To find the maximum element of a vector.
*min_element (first_iterator, last_iterator) – To find the minimum element of a vector.
accumulate(first_iterator, last_iterator, initial value of sum) – Does the summation of vector elements
count(first_iterator, last_iterator,x) – To count the occurrences of x in vector.
find(first_iterator, last_iterator, x) – Points to last address of vector ((name_of_vector).end()) if element is not present in vector.
binary_search(first_iterator, last_iterator, x) – Tests whether x exists in sorted vector or not.
lower_bound(first_iterator, last_iterator, x) – returns an iterator pointing to the first element in the range [first,last) which has a value not less than ‘x’.
upper_bound(first_iterator, last_iterator, x) – returns an iterator pointing to the first element in the range [first,last) which has a value greater than ‘x’.
arr.erase(position to be deleted) – This erases selected element in vector and shifts and resizes the vector elements accordingly.
arr.erase(unique(arr.begin(),arr.end()),arr.end()) – This erases the duplicate occurrences in sorted vector in a single line.
next_permutation(first_iterator, last_iterator) – This modified the vector to its next permutation.
prev_permutation(first_iterator, last_iterator) – This modified the vector to its previous permutation.
 */

 char graph[50][50];
 bool visited[50][50];
deque<pll> que;
 vl row;
 vl cols;

 void move(ll a,ll b)
 {
   ll i,j,k,l;
    while(!que.empty())
    {
        pll top = que.front();
        que.pop_front();

        // cout<<"YO"<<endl;

        row[top.first]++;
        cols[top.second]++;

        // cout<<top.first<<" "<<top.second<<endl;

        // graph[top.first][top.second] = '.';

        for(i=0;i<a;i++)
        {
           if(graph[i][top.second]=='#' && visited[i][top.second]==false)
           {
            visited[i][top.second] = true;
            que.pb(mp(i,top.second));
            // cout<<"YO"<<endl;

           }
        }

        for(i=0;i<b;i++)
        {
           if(graph[top.first][i]=='#' && visited[top.first][i]==false)
           {
            visited[top.first][i] = true;
            que.pb(mp(top.first,i));
            // cout<<"YO"<<endl;

           }
        }
    }
 }

int main()
{
    fastio;

    ll a,b,c,i,j,k,l,m,n,t,p;

    cin>>a>>b;

    for(i=0;i<a;i++)
    {
        for(j=0;j<b;j++)
        {
            cin>>graph[i][j];
            visited[i][j] = false;
        }
    }

    vl row_fin(a,0);
    vl cols_fin(b,0);

    bool possible = true;

    for(i=0;i<a;i++)
    {
        for(j=0;j<b;j++)
        {
            if(graph[i][j]=='#')
            {
                row.clear();
                que.clear();
                cols.clear();
                for(k=0;k<50;k++){
                    row.pb(0);
                    cols.pb(0);
                }
                // row[i]++;
                // cols[j]++;

                que.pb(mp(i,j));

                move(a,b);

                // for(k=0;k<a;k++)
                //     cout<<row[k]<<" ";
                // cout<<endl;

                // for(k=0;k<b;k++)
                //     cout<<cols[k]<<" ";
                // cout<<endl;

                for(m=0;m<a;m++)
                {
                    for(n=0;n<b;n++)
                    {
                        if(row[m] && cols[n])
                        {
                            if(graph[m][n]=='.')
                                possible = false;
                            else
                                graph[m][n] = '.';
                        }
                    }
                }

                for(k=0;k<a;k++)
                {
                    if(row[k]){
                        row_fin[k]++;
                        if(row_fin[k]>1)
                            possible =false;
                    }
                }

                for(k=0;k<b;k++)
                {
                    if(cols[k]){
                        cols_fin[k]++;
                        if(cols_fin[k]>1)
                            possible = false;
                    }
                }
            }
        }
    }

    if(possible)
        cout<<"Yes"<<endl;
    else
    {
        cout<<"No"<<endl;
    }

}


#include <bits/stdc++.h>
using namespace std;
#define ll long long
int main() {
	ll n,m;
	cin>>n>>m;
	string arr[n];
	for(ll i=0;i<n;i++){
	    cin>>arr[i];
	}
	bool flag=true;
	for(ll i=0;i<n;i++){
	    for(ll k=0;k<n;k++){
	    if(arr[i]==arr[k]){

	    }else{
	    bool flag1=true;
	    for(ll j=0;j<m;j++){
	        if((arr[i][j]=='#' && arr[k][j]=='#')){
	            flag1=false;
	            break;
	        }
	    }
	    if(flag1==false){
	        flag=false;
	        break;
	    }
	    }
	    }
	}
	if(flag){
	    cout<<"Yes"<<endl;
	}else{
	    cout<<"No"<<endl;
	}
}


#include <bits/stdc++.h>
using namespace std;
#define ll long long
int main() {
	ll n,m;
	cin>>n>>m;
	string arr[n];
	for(ll i=0;i<n;i++){
	    cin>>arr[i];
	}
	bool flag=true;
	for(ll i=0;i<n-1;i++){
	    if(arr[i]==arr[i+1]){

	    }else{
	    bool flag1=true;
	    for(ll j=0;j<m;j++){
	        if((arr[i][j]=='#' && arr[i+1][j]=='.') || (arr[i][j]=='.' && arr[i+1][j]=='#')){
	            flag1=false;
	            break;
	        }
	    }
	    if(flag1==false){
	        flag=false;
	        break;
	    }
	    }
	}
	if(flag){
	    cout<<"Yes"<<endl;
	}else{
	    cout<<"No"<<endl;
	}
}


#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("O3")
#pragma GCC optimize("fast-math")
#include <bits/stdc++.h>

#define ff first
#define ss second
#define pb emplace_back
#define all(x) x.begin(),x.end()
#define rall(x) (x).rbegin(),(x).rend()
#define re return
#define mp make_pair
#define sz(x) ((int)(x).size())
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rrep(i, n) for (int i = (n) - 1; i >= 0; i--)
#define repx(i, x, n) for(int i = x; i < n; i++)
#define repd(i, x, n, d) for(int i = x; i < n; i += d)
#define rrepx(i, x, n) for(int i = n - 1; i >= x; i--)
#define rrepd(i, x, n, d) for(int i = n - 1; i >= x; i -= d)
#define unq(x); { sort(x.begin(), x.end()); x.resize(unique(x.begin(), x.end()) - x.begin()); }
#define sqr(x) ((x)*(x))

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ld, ld> pdd;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vii;
typedef vector<pll> vll;
typedef vector<string> vs;
typedef vector<ll> vl;
typedef vector<vl> vvl;

//#define DEBUG 1
//#define FILES 1

#ifdef DEBUG
#define debug(x)   cerr << #x << " " << x << endl;
#define debug_p(x) cerr << #x << " " << x.ff << " " << x.ss << endl;
#define debug_v(x) {cerr << #x << " "; for (auto i : x) cerr << i << " "; cerr << endl;}
#define debug_vp(x) {cerr << #x << " "; for (auto i : x) cerr << '[' << i.ff << " " << i.ss << ']'; cerr << endl;}
#define debug_v_v(x) {cerr << #x << "/*\n"; for (auto i : x) { for (auto i2 : i) cerr << i2 << " "; cerr << '\n';} cerr << "*/" << #x << endl;}
#else
#define debug(x) 0;
#define debug_p(x) 0;
#define debug_v(x) 0;
#define debug_vp(x) 0;
#define debug_v_v(x) 0;
#endif

#ifdef FILES
#define files(in, out); { freopen(in, "r", stdin); freopen(out, "w", stdout);}
#else
#define files(in, out) 0;
#endif

const int INF = 1e9;
const ll INFll = 2e18;
const int BASE1 = 179;
const int BASE2 = 653;
const ll MOD = 1e9 + 7;
const int MAXN = 2e5;
const ld PI = 3.1415926535;
const ld EPS = 1e-10;

void solve() {
    int n, m;
    cin >> n >> m;
    vvi a(n, vi(m, 0));
    rep(i, n) {
        rep(j, m) {
            char c;
            cin >> c;
            a[i][j] = (c == '#');
        }
    }
    bool flag = true;
    rep(i1, n) {
        rep(i2, n) {
            rep(j1, m) {
                rep(j2, m) {
                    if (i1 != i2 && j1 != j2 && a[i1][j1] + a[i1][j2] + a[i2][j1] + a[i2][j2] == 3)
                        flag = false;
                }
            }
        }
    }
    if (flag)
        cout << "Yes\n";
    else
        cout << "No\n";
}

signed main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    int t = 1;
    //cin >> t;
    while (t--)
        solve();
    return 0;
}

/*
⣿⣿⣿⣿⡿⠋⠁⢀⢀⢀⠹⣿⣿⣿⣿⣿⣿⣿⣿⠏⢀⢀⢀⠈⠙⢿⣿⣿⣿⣿
⣿⣿⣿⡟⢀⢀⢀⢀⠠⢀⢀⣿⣿⣿⣿⣿⣿⣿⣿⢀⢀⠄⢀⢀⢀⢀⢻⣿⣿⣿
⣿⣿⡟⢀⢀⢀⢀⢀⢀⢀⢀⣿⣿⣿⣿⣿⣿⣿⣿⡀⢀⢀⢀⢀⢀⢀⢀⢻⣿⣿
⣿⣿⡇⢀⢀⢀⢀⢀⢀⢀⣮⣿⣿⣿⣿⣿⣿⣿⣿⣵⡀⢀⢀⢀⢀⢀⢀⢸⣿⣿
⣿⣿⡀⢀⢀⢀⢀⢀⣴⣿⣯⡛⠋⠁⢻⡟⠈⠙⢛⣽⣿⣦⡀⢀⢀⢀⢀⢀⣿⣿
⣿⣿⡇⢀⢀⢀⢾⣿⠟⠋⠁⢀⢀⢀⢀⢀⢀⢀⢀⠈⠙⠻⣿⡷⢀⢀⢀⢸⣿⣿
⠛⠛⣷⡀⢀⢀⠈⠁⢀⢀⢀⢀⢀⢀⢀⢀⢀⢀⢀⢀⢀⢀⠈⠁⢀⢀⢀⣾⠛⠛
⡀⢀⠈⠻⣶⠄⢀⢀⢀⢀⢀⢀⢀⢀⢀⢀⢀⢀⢀⢀⢀⢀⢀⢀⠠⣶⠟⠁⢀⢀
⣷⣄⣀⢀⢀⢀⢀⢀⢀⢀⢀⢀⢀⢀⢀⢀⢀⢀⢀⢀⢀⢀⢀⢀⢀⢀⢀⣀⣠⣾
⠛⠛⠛⠶⠶⢀⢀⢀⢀⢀⢀⢀⢀⢀⢀⢀⢀⢀⢀⢀⢀⢀⢀⢀⢀⠶⠶⠛⠛⠛
⣆⡀⢀⢀⢀⢀⢀⠄⢀⢀⢀⢀⢀⢀⢀⢀⢀⢀⢀⢀⢀⢀⠠⡀⢀⢀⢀⢀⢀⣰
⣿⣿⡿⠶⠚⠉⢀⢀⢀⠂⢀⢀⢀⢀⢀⢀⢀⢀⢀⢀⠐⡀⢀⢀⠉⠓⠶⢿⣿⣿
⣿⠋⢀⢀⢀⢀⣠⡴⠋⢀⢀⣠⣶⣶⣶⣶⣶⣶⣄⢀⢀⠙⢦⣄⢀⢀⢀⢀⠙⣿
⣿⣿⣷⣾⣿⣿⣿⡇⢀⢀⢀⣿⣿⣿⣿⣿⣿⣿⣿⡀⢀⢀⢸⣿⣿⣿⣷⣾⣿⣿
⣿⣿⣿⣿⣿⣿⣿⣷⢀⢀⣸⣿⣿⣿⣿⣿⣿⣿⣿⣇⢀⢀⣾⣿⣿⣿⣿⣿⣿⣿
*/


#include <bits/stdc++.h>

using namespace std;

int main()
{
        ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
        int n, m, i, j;
        cin>>n>>m;
        map<int, set<int> > in;
        map<int, set<int> >::iterator o;
        set<int>::iterator t;
        char v[50][50];
        for(i=0; i<n; i++)
        {
                for(j=0; j<m; j++)
                cin>>v[i][j];
        }
        for(i=0; i<n;)
        {
                set<int> s;
                for(j=0; j<m; j++)
                {
                        if(v[i][j]=='#') s.insert(j);
                }
                int f=1;
                for(o=in.begin(); o!=in.end(); o++)
                {
                        set<int> k=o->second;
                        if(s==k) break;
                        else{
                                for(t=s.begin(); t!=s.end(); t++)
                                {
                                        if(k.find(*t)!=k.end())
                                        f=0;
                                }
                        }
                }
                if(f==0) break;
                else{
                        in.insert({i, s});
                        i++;
                }
        }
        if(i==n) cout<<"Yes";
        else cout<<"No";
        return 0;
}


#include <bits/stdc++.h>

using namespace std;

#define range(i, m, n) for(int i = m; i < n; i++)
#define husk(i, m, n) for(int i = m; i > n; i--)

int n, m;

int main() {
  cin >> n >> m;
  vector<long long> cur;
  range(i, 0, n) {
    string s;
    cin >> s;
    long long b = 0;
    range(j, 0, m) if(s[j] == '#') b ^= 1LL << j;
    cur.push_back(b);
  }
  for(auto i : cur) {
    for(auto j : cur) {
      if(i == j) continue;
      if(i & j) {
        cout << "No";
        return 0;
      }
    }
  }
  cout << "Yes";
  return 0;
}


#include <functional>
#include <fstream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <list>
#include <time.h>
#include <math.h>
#include <unordered_set>
#include <unordered_map>
#include <iomanip>
#include <deque>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <sstream>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <bitset>
#include <iostream>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef double db;
typedef string str;

typedef pair<int,int> pi;
typedef pair<ll,ll> pl;
typedef pair<db,db> pd;

typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<db> vd;
typedef vector<str> vs;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<pd> vpd;

typedef set<int> si;
typedef set<ll> sl;
typedef set<db> sd;
typedef set<str> ss;
typedef set<pi> spi;
typedef set<pl> spl;
typedef set<pd> spd;

#define mp make_pair
#define f first
#define s second
#define sz(x) (int)(x).size()
#define all(x) begin(x), end(x)
#define rall(x) (x).rbegin(), (x).rend()
#define rsz resize
#define ins insert
#define ft front()
#define bk back()
#define pf push_front
#define pb push_back
#define eb emplace_back
#define lb lower_bound
#define ub upper_bound

#define forr(i,a,b) for (int i = (a); i < (b); i++)
#define ford(i,a,b) for (int i = (a)-1; i >= (b); i--)
#define trav(a,x) for (auto& a: x)

const ll MOD = 1e9+7;
int gcd(int a,int b){return b?gcd(b,a%b):a;}
ll binpow(ll a,ll b){ll res=1;while(b){if(b&1)res=(res*a)%MOD;a=(a*a)%MOD;b>>=1;}return res;}
ll modInv(ll a){return binpow(a, MOD-2);}
bool sortcol(const vl& v1, const vl& v2) {return v1[1] < v2[1];}

template<class T> bool ckmin(T& a, const T& b) {
	return b < a ? a = b, 1 : 0; }
template<class T> bool ckmax(T& a, const T& b) {
	return a < b ? a = b, 1 : 0; }
int pct(int x) { return __builtin_popcount(x); }
int bits(int x) { return 31-__builtin_clz(x); } // floor(log2(x))
int cdiv(int a, int b) { return a/b+!(a<0||a%b == 0); } // division of a by b rounded up, assumes b > 0
int fstTrue(function<bool(int)> f, int lo, int hi) {
	hi ++; assert(lo <= hi); // assuming f is increasing
	while (lo < hi) { // find first index such that f is true
		int mid = (lo+hi)/2;
		f(mid) ? hi = mid : lo = mid+1;
	}
	return lo;
}

mt19937 rng((uint32_t)chrono::steady_clock::now().time_since_epoch().count());

#define debug(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)
#define time__(d) for(long blockTime = 0; (blockTime == 0 ? (blockTime=clock()) != 0 : false); debug("%s time : %.4fs", d, (double)(clock() - blockTime) / CLOCKS_PER_SEC))

// ifstream cin("");
// ofstream cout("");

const int mxN = 2e5;
int q = 1, n, m, arr[55][55];
str s;
// bool a, b;

void solve() {
	cin >> n >> m;
	forr(i,0,n) {
		cin >> s;
		forr(j,0,m) {
			if (s[j] == '#') arr[i][j] = 1;
		}
	}
	bool ans = 1;
	forr(i,0,n) {
		forr(j,i+1,n) {
			bool a = 0, b = 0;
			forr(k,0,m) {
				if (arr[i][k] == 1 && arr[j][k] == 1) {
					a = 1;
				}
				if (arr[i][k] != arr[j][k]) {
					b = 1;
				}
			}
			if (a&&b) ans = 0;
		}
	}
	if (!ans) cout << "No\n";
	else cout << "Yes\n";
}

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);

	// cin >> q;
	while(q--) {
		solve();
	}
}


#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <string>
#include <deque>
#include <math.h>
#include <cassert>
#include <bitset>
#include <iomanip>
#define ld long double
#define dd double
#define ll long long
using namespace std;
ll inf = 1e9 + 123;
ll eps = 1e-6;

int main() {
	//freopen("typing.in", "r", stdin);freopen("typing.out", "w", stdout);
	//freopen("input.txt", "r", stdin);
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	int n, m;
	cin >> n >> m;
	vector<vector<int> > tocheck(m);
	vector<bitset<50> > y(m);
	vector<vector<int> > x(n);
	int i, j;
	char ch;
	for (i = 0; i < n; i++) {
		for (j = 0; j < m; j++) {
			cin >> ch;
			if (ch == '#') {
				x[i].push_back(j);
				y[j].set(i);
				tocheck[j].emplace_back(i);
			}
		}
	}
	vector<bool> used(m, 0);
	for (i = 0; i < m; i++) {
		for (int k : tocheck[i]) {
			for (int j : x[k]) {
				used[j] = 1;
				if ((y[i] ^ y[j]) != 0) {
					cout << "NO";
					return 0;
				}
			}
		}
	}
	cout << "YES";
}


#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <string>
#include <deque>
#include <math.h>
#include <cassert>
#include <bitset>
#include <iomanip>
#define ld long double
#define dd double
#define ll long long
using namespace std;
ll inf = 1e9 + 123;
ll eps = 1e-6;

int main() {
	//freopen("typing.in", "r", stdin);freopen("typing.out", "w", stdout);
	//freopen("input.txt", "r", stdin);
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	int n, m;
	cin >> n >> m;
	vector<int> tocheck(m, -1);
	vector<bitset<50> > y(m);
	vector<vector<int> > x(n);
	int i, j;
	char ch;
	for (i = 0; i < n; i++) {
		for (j = 0; j < m; j++) {
			cin >> ch;
			if (ch == '#') {
				x[i].push_back(j);
				y[j].set(i);
				tocheck[j] = i;
			}
		}
	}
	vector<bool> used(m, 0);
	for (i = 0; i < m; i++) {
		if (tocheck[i] == -1)
			continue;
		for (int j : x[tocheck[i]]) {
			used[j] = 1;
			if ((y[i] ^ y[j]) != 0) {
				cout << "NO";
				return 0;
			}
		}
	}
	cout << "YES";
}


#include<bits/stdc++.h>
#define FAST ios_base::sync_with_stdio(false);cin.tie();cout.tie();
#define FILE_READ_IN freopen("input.txt","r",stdin);
#define FILE_READ_OUT freopen("output.txt","w",stdout);
using namespace std;
typedef long long ll;
typedef long double ld;
#define MAX_N 300
#define neg_infinte -10000000
#define infinite 100000000

void solve(){
   int n,m; cin>>n>>m;
   int g[n][m];
   for(int i=0;i<n;i++)
   {
      for(int j=0;j<m;j++)
      {
         char c; cin>>c;
         g[i][j]=(c=='#');
      }
   }
   for(int i=0;i<n;i++)
   {
      for(int j=0;j<n;j++)
      {
         bool allsame=true,nointersect=true;
         for(int k=0;k<m;k++)
         {
            if(g[i][k]!=g[j][k]) allsame=false;
            if(g[i][k]&&g[j][k]) nointersect=false;
         }
         if (!allsame&&!nointersect)
         {
            cout << "NO\n";
            return;
         }
      }
   }
   cout<<"YES\n";
}

int main(){
   FAST
   #ifndef ONLINE_JUDGE
   FILE_READ_IN
   FILE_READ_OUT
   #endif
   int t=1;  //cin>>t;
   while (t--)
   {
      solve();
   }
   return 0;
}


#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

const int M = 1e9+7 ;

int main(){

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int n , m  ;
    cin>> n >> m  ;

    vector<string> B (n );

    for(int i = 0 ; i < n ; ++i){
        cin >> B[i];
    }

    vector<vector<int>> A (n , vector<int>(m));
    for(int i = 0; i < n ; ++i){
        for(int j = 0 ; j < m ;++j){
            A[i][j] = (B[i][j] == '#');
        }
    }

    for(int i = 0 ; i < n ; ++i){
        for(int j = i +1; j < n ; ++j){
            bool allsame = true,  nointersect = true;

            for(int k = 0 ; k < m  ;++k){
                if (A[i][k] != A[j][k]) allsame = false;
                if (A[i][k] && A[j][k]) nointersect = false;
            }

            if (!allsame && !nointersect){
                cout << "No" <<"\n";
                return 0;

            }
        }
    }

    cout << "Yes" << "\n";

    return 0;
}


#define _USE_MATH_DEFINES
#include<iostream>
#include<fstream>
#include<string>
#include<vector>
#include<utility>
#include<algorithm>
#include<climits>
#include<set>
#include<map>
#include<cmath>
#include<iomanip>
#include<iterator>
#include<queue>
#include<stack>
#include<cctype>
#include<deque>
#include<time.h>
#include<bitset>
#include<random>
#include<unordered_set>
#include<unordered_map>
#include<sstream>
#include<random>
#include<numeric>

//by Skeef79

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

#pragma warning(disable : 4996)
#pragma comment(linker, "/STACK:16777216")
#define pb push_back
#define en '\n'
#define for0(i,n) for(int i = 0;i<n;i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define vec vector
#define pii pair<int,int>
#define pll pair<ll,ll>
#define what_is(x) cout<<#x<<" is "<<x<<en;

using namespace std;

const int INF = 2000000000;
const ll LINF = 2000000000000000000;

template<typename T> void print(vector<T>& a)
{
	for (int i = 0; i < a.size(); i++)
		cout << a[i] << ' ';
	cout << en;
}

template<typename T> void print(deque<T>& a)
{
	for (int i = 0; i < a.size(); i++)
		cout << a[i] << ' ';
	cout << en;
}

template<typename T> void print(vector<vector<T>>& a)
{
	for (int i = 0; i < a.size(); i++)
	{
		for (int j = 0; j < a[i].size(); j++)
			cout << a[i][j] << ' ';
		cout << en;
	}
}

template <typename T> void input(vector<T>& a)
{
	for (int i = 0; i < a.size(); i++)
		cin >> a[i];
}

template<typename T> void input(deque<T>& a)
{
	for (int i = 0; i < a.size(); i++)
		cin >> a[i];
}

template<typename T> void input(vector<vector<T>>& a)
{
	for (int i = 0; i < a.size(); i++)
		for (int j = 0; j < a[i].size(); j++)
			cin >> a[i][j];
}

void solve()
{
	int n, m;
	cin >> n >> m;
	//getchar();
	vector<vector<int>>a(n, vector<int>(m));
	for (int i = 0; i < n; i++)
		for (int j = 0; j < m; j++)
		{
			char c;
			cin >> c;
			a[i][j] = (c == '#');
		}

	for(int i = 0;i<n;i++)
		for (int j = i + 1; j < n; j++)
		{
			bool diff = false;
			bool intersect = false;
			for (int k = 0; k < m; k++)
			{
				if (a[i][k] != a[j][k])
					diff = true;
				if (a[i][k] && a[j][k])
					intersect = true;
			}
			if (diff && intersect)
			{
				cout << "No";
				return;
			}
		}
	cout << "Yes";
}

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);

#ifdef _DEBUG
	freopen("input.txt", "r", stdin);
#endif

	int tst = 1;
	//cin >> tst;
	while (tst--)
		solve();

}


#include<bits/stdc++.h>
using namespace std;

#define ll long long

int n,m;
char table[51][51];

int main()
{
//    freopen("a.in","r",stdin);
    cin>>n>>m;
    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=m;j++)
        {
            cin>>table[i][j];
        }
    }
    for(int i=1;i<=n;i++)
    {
        vector <int> same;
        for(int j=1;j<=m;j++)
        {
            if(table[i][j]=='#')
            {
                same.push_back(j);
            }
        }
        vector <int>p[51];
        for(int j=0;j<same.size();j++)
        {
            for(int k=1;k<=n;k++)
            {
                if(table[k][same[j]]=='#')
                {
                    p[j].push_back(k);
                }for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=m;j++)
        {
            cin>>table[i][j];
        }
    }
            }
        }
        for(int j=1;j<same.size();j++)
        {
            if(p[j]!=p[j-1])
            {
                cout<<"No";return 0;
            }
        }
    }
    cout<<"Yes";
}


#include<bits/stdc++.h>
using namespace std;

#define ll long long

int n,m;
char table[51][51];

int main()
{
//    freopen("a.in","r",stdin);
    cin>>n>>m;
    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=m;j++)
        {
            cin>>table[i][j];
        }
    }
    for(int i=1;i<=n;i++)
    {
        vector <int> same;
        for(int j=1;j<=m;j++)
        {
            if(table[i][j]=='#')
            {
                same.push_back(j);
            }
        }
        vector <int>p[51];
        for(int j=0;j<same.size();j++)
        {
            for(int k=1;k<=n;k++)
            {
                if(table[k][same[j]]=='#')
                {
                    p[j].push_back(k);
                }
            }
        }
        for(int j=1;j<same.size();j++)
        {
            if(p[j]!=p[j-1])
            {
                cout<<"No";return 0;
            }
        }
    }
    cout<<"Yes";
}


#include <bits/stdc++.h>
#include<stdint.h>
using namespace std;
#define ll long long
#define MOD 1000000007
#define N (int)2e5 + 5
#define pb push_back
#define mod 998244353
#define ff first
#define ss second

/*ll po(ll x,ll n) {
    if(n == 0)
        return 1;
    else if(n % 2 == 0)
        return po((x * x) % mod, n / 2);
    else
        return (x * po((x * x) % mod, (n - 1) / 2)) % mod;

}*/
/*
bool prime(int x) {
    if (x < 2) return false;
    for (int i = 2; i*i <= x; ++i) {
        if (x%i == 0) return false;
    }
    return true;
}
bool sortbysec(const pair<int,int> &a, const pair<int,int> &b) {
    if(a.second < b.second) return true;
    else if(a.ss==b.ss) return a.ff<b.ff;
	else return false;
}*/
/*
bool sortbyboth(const pair<int,int> &a, const pair<int,int> &b) {
	if(a.first<b.first) return true;
	else if(a.first==b.first) return a.second<b.second;
	else return false;
}
*/
/*
bool sortbytwo(const pair<int,int> &a, const pair<int,int> &b) {
	if(a.first>b.first) return true;
	else if(a.first==b.first) return a.ss<b.ss;
	else return false;
}
*/
/*ll fact(ll n) {
    ll fa[n + 1];
    fa[1] = 1;
    for(ll i = 2; i <= n; i++) {
        fa[i] = (fa[i - 1] * i) % mod;
    }
    return fa[n];
}
*/
/*
bool isPrime(int n) {
    int count = 0;
    for(int i = 1;i <= sqrt(n); i++)  {
        if(n % i == 0) {
            count++;
            if(n / i != i)
                count++;
        }
    }
    if(count == 2)
        return true;
    else
        return false;
}
*/

void solve()
{
    int n, m;
    cin >> n >> m;
    bool a[n][m];
    char ch;
    for(int i = 0; i < n; i++)
        for(int j = 0; j < m; j++)
            cin >> ch,  a[i][j] = (ch == '#');

    for(int i = 0; i < n- 1; i++) {
        for(int j = i + 1; j < n; j++) {
            bool same = 1, inter = 1;
            for(int k = 0; k < m; k++) {
                if(a[i][k] != a[j][k])
                    same = 0;
                if(a[i][k] && a[j][k])
                    inter = 0;
            }
            if(!same && !inter) {
                cout << "No";
                return;
            }
        }
    }
    cout << "Yes";
}

int32_t main()
{
    //freopen("input.txt", "r", stdin);     //freopen("output.txt", "w", stdout);
    ios::sync_with_stdio(false);    cin.tie(nullptr);
    int t = 1;
    //cin >> t;

    loop: while(t--) {
        solve();
    }

}


#include <bits/stdc++.h>
#define endl '\n'
#define modulo 998244353
#define PI acos(-1)
#pragma GCC target ("avx2")
#pragma GCC optimize("trapv")
#define int long long
#define sinDegrees(x) sin((x) * PI / 180.0)
#define cosDegrees(x) cos((x) * PI / 180.0)
#define tanDegrees(x) tan((x) * PI / 180.0)
#define atanDegrees(x) atan(x)* 180.0 / PI
using namespace std;
int power(int x,int y,int m)
{
int temp;
if(y == 0)
return 1;
temp = (power(x, y/2,m))%m;
if (y%2 == 0)
return ((temp%m)*temp);
else
return ((x*temp%m)*temp%m)%m;
}
int inv(int x)
{
return (power(x,modulo-2,modulo))%modulo;
}
bool comp(int a,int b)
{
return a>b;
}
bool visited[51];
int32_t main()
{
//freopen("output.txt","w", stdout);
//freopen("rect.in","r", stdin);
iostream::sync_with_stdio(0);
cin.tie(0);
int n,m;
cin>>n>>m;
set<string>ss;
string s;
for(int i=0;i<n;i++){
cin>>s;
ss.insert(s);
}
auto itr=ss.begin();
for(itr;itr!=ss.end();itr++){
string q=(*itr);
for(int l=0;l<q.size();l++){
if(q[l]=='#'&&!visited[l])
visited[l]=1;
else if(q[l]=='#'){
cout<<"NO";exit(0);
}
}
}
cout<<"YES";
return 0;
}


#include <bits/stdc++.h>
using namespace std;
int main() {
    int n, m;
    cin >> n >> m;
    string grid[n];
    for (int i = 0; i < n; i++) {
        cin >> grid[i];
    }
    vector<bool> checked(n);
    for (int i = 0; i < n ; i++) {
        for (int j = i+1; j < n; j++) {
            bool same = true, intersection = false;
            for (int k = 0; k < m; k++) {
                same &= grid[i][k] == grid[j][k];
                intersection |= grid[i][k] == '#' && grid[j][k] == '#';
            }
            if (!same && intersection) {
                cout << "No";
                return 0;
            }
        }
    }
    cout << "Yes";
}


#include <bits/stdc++.h>
using namespace std;
int main() {
    int n, m;
    cin >> n >> m;
    string grid[n];
    for (int i = 0; i < n; i++) {
        cin >> grid[i];
    }
    vector<bool> checked(n);
    for (int i = 0; i < n; i++) {
        vector<int> R;
        if (grid[i].find('#') != string::npos && !checked[i]) {
            for (int j = i, m = grid[i].find('#'); j < n; j++) {
                if (grid[i][m] == grid[j][m]) {
                    checked[j] = true;
                    R.push_back(j);
                }
            }
            for (int j = 0; j < m; j++) {
                for (int r1 : R) {
                    for (int r2 : R) {
                        if (grid[r1][j] != grid[r2][j]) {
                            cout << "No";
                            return 0;
                        }
                    }
                }
            }
        }
    }
    cout << "Yes";
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define OJ \
    freopen("input.txt", "r", stdin); \
    freopen("output.txt", "w", stdout);
#define FIO ios::sync_with_stdio(0);cin.tie(0);
int main(){
FIO;
int n,m;
cin>>n>>m;
vector<string> v;
for(int i=0;i<n;i++){
    string s;
    cin>>s;
    v.push_back(s);
}
for(int i=0;i<n;i++){
    for(int j=0;j<m;j++){
        if(v[i][j]=='#'){
            for(int k=0;k<n;k++){
                if(k==i) continue;
                if(v[k][j]==v[i][j] && v[i]!=v[k]){
                    cout<<"No"<<"\n";
                    return 0;
                }
            }
        }
    }
}
cout<<"Yes"<<"\n";

}


#include <iostream>
#include <string>
#include <sstream>
#include <iomanip>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <functional>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <bitset>

using namespace std;

// Union-Find Disjoint Sets Library written in OOP manner, using both path compression and union by rank heuristics
// initialize: UnionFind UF(N)

class UnionFind {                                              // OOP style
private:
	vector<int> p, rank, setSize;
	// p = path toward the root of disjoint set; p[i] = i means it is root
	// rank = upper bound of the actual height of the tree; not reliable as accurate measure
	// setSize = size of each disjoint set

	int numSets;
public:
	UnionFind(int N) {
		setSize.assign(N, 1);
		numSets = N;
		rank.assign(N, 0);
		p.assign(N, 0);
		for (int i = 0; i < N; i++) p[i] = i;	// each belongs to its own set
	}

	int findSet(int i) {
		return (p[i] == i) ? i : (p[i] = findSet(p[i]));		// path compression: cut short of the path if possible
	}

	bool isSameSet(int i, int j) {
		return findSet(i) == findSet(j);
	}

	void unionSet(int i, int j) {
		if (!isSameSet(i, j)) {
			numSets--;
			int x = findSet(i), y = findSet(j);
			// rank is used to keep the tree short
			if (rank[x] > rank[y]) { p[y] = x; setSize[x] += setSize[y]; }
			else {
				p[x] = y; setSize[y] += setSize[x];
				if (rank[x] == rank[y]) rank[y]++;
			}
		}
	}

	int numDisjointSets() {		// # of disjoint sets
		return numSets;
	}

	int sizeOfSet(int i) {		// size of set
		return setSize[findSet(i)];
	}
};

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);

	int n, m, i, j, k, last;
	cin >> n >> m;
	vector<string> s(n);

	UnionFind uf(n + m);

	for (i = 0; i < n; i++) {
		cin >> s[i];
		last = -1;
		for (j = 0; j < m; j++) {
			if (s[i][j] == '#') {
				uf.unionSet(i, j + n);
				if (last == -1) last = j;
				else uf.unionSet(last + n, j + n);
			}
		}
	}

	bool valid = true;
	for (i = 0; i < n; i++) {
		for (j = 0; j < m; j++) {
			if ((s[i][j] == '.') && (uf.isSameSet(i, j + n))) valid = false;
		}
	}

	if (valid) cout << "YES\n";
	else cout << "NO\n";

	return 0;
}


#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define ST first
#define ND second
#define ll long long
#define ld long double
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
using namespace std;
using namespace __gnu_pbds;

// replace ll  with pair if multiset needed
typedef tree<ll , null_type, greater<ll >, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
ordered_set secik;

const ll  INF = 1e9 + 9;
const ll  MOD = 1e9 + 7;
const long long LINF = (ll)1e18 + 3;

// secik.insert({x, t++});
// secik.erase(secik.lower_bound({x,-1}));
// *secik.find_by_order(x)).first << "\n";
// secik.order_of_key(x)

//random_device device;
//mt19937 gener(device());
//uniform_int_distribution<ll > gen(0,n-1);
//gen(gener); // generate random number

const int SIZE = 60;

char tab[SIZE][SIZE];

int main(){
	ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);

	int n,m; cin >> n >> m;

	for(int i = 0; i < n; i++)
		for(int j = 0; j < m; j++)
			cin >> tab[i][j];

	bool ok = true;

	for(int i = 0; i < n; i++)
		for(int j = i + 1; j < n; j++){
			bool same = true, intersect = false;
			for(int k = 0; k < m; k++){
				if(tab[i][k] != tab[j][k]) same = false;
				if(tab[i][k] == tab[j][k] && tab[i][k] == '#') intersect = true;
			}
			if(!same && intersect) ok = false;
		}

	if(ok) cout << "Yes\n";
	else cout << "No\n";

}


#include<bits/stdc++.h>

#define int long long int
#define mp make_pair
using namespace std;

bool row[52],col[52];
bool visited[52][52];

int32_t main() {
    int n,m;
    scanf("%lld", &n);
    scanf("%lld", &m);
    string s[n+2];
    for (int i = 0; i < n; ++i) {
        cin >> s[i];
    }
    for (int i = 0; i < n; ++i) {
        set <int> rows;
        if(row[i] == false) {
            for (int j = 0; j < m; ++j) {
                if(col[j] == false) {
                    if (s[i][j] == '#') {
                        row[i] = true;
                        col[j] = true;
                        visited[i][j] = true;
                        for (int k = i + 1; k < n; ++k) {
                            /*if(row[k] == true){
                                printf("%lld %lld here",i,j);
                                printf("NO");
                                return 0;
                            }*/
                            /*row[k] = true;*/
                            if(s[k][j] == '#') {
                                visited[k][j] = true;
                                rows.insert(k);
                            }
                        }
                    }
                }
            }
        }
        for (auto i = rows.begin(); i != rows.end() ; ++i) {
            if(row[*i] == false){
                row[*i] = true;
            }
            else{
                //printf("here");
                printf("No");
                return 0;
            }
        }
    }
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < m; ++j) {
            if(s[i][j] == '#'){
                if(visited[i][j] == false){
                   // printf("here1");
                    printf("No");
                    return 0;
                }
            }
        }
    }
    printf("Yes");
    return 0;
}


#include<bits/stdc++.h>

#define int long long int
#define mp make_pair
using namespace std;

bool row[52],col[52];
bool visited[52][52];

int32_t main() {
    int n,m;
    scanf("%lld", &n);
    scanf("%lld", &m);
    string s[n+2];
    for (int i = 0; i < n; ++i) {
        cin >> s[i];
    }
    for (int i = 0; i < n; ++i) {
        set <int> rows,cols;
        if(row[i] == false) {
            for (int j = 0; j < m; ++j) {
                if(col[j] == false) {
                    if (s[i][j] == '#') {
                        rows.insert(i);
                        cols.insert(j);
                        for (int k = i + 1; k < n; ++k) {
                            if(s[k][j] == '#'){
                                rows.insert(k);
                            }
                        }
                    }
                }
            }
        }
        for (auto l = rows.begin(); l != rows.end() ; ++l) {
            if(row[*l] == true){
                printf("No");
                return 0;
            }
        }
        for (auto l = cols.begin(); l != cols.end() ; ++l) {
            if(col[*l] == true){
                printf("No");
                return 0;
            }
        }
        for (auto l = rows.begin(); l != rows.end() ; ++l) {
            row[*l] = true;
            for (auto k = cols.begin(); k != cols.end() ; ++k) {
                if(s[*l][*k] == '.'){
                    printf("No");
                    return 0;
                }
                col[*k] = true;
                visited[*l][*k] = true;
            }
        }
    }
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < m; ++j) {
            if(s[i][j] == '#'){
                if(visited[i][j] == false){
                   // printf("here1");
                    printf("No");
                    return 0;
                }
            }
        }
    }
    printf("Yes");
    return 0;
}


#define _CRT_NO_WARNINGS
#include<iostream>
#include<fstream>
#include<cmath>
#include<algorithm>
#include<cstdlib>
#include<queue>
#include<map>
#include<string>
#include<stack>
#include<vector>
#include<set>
#include<iomanip>

using namespace std;
#define int long long
#define fi(i,a,b) for(int i = a; i < (b); i++)
const int N = 200005;

//big arrays' declaration here

int columnIters[55];
int A[55][55];
bool B[55][55];
char inputStr[55];

void main() {
#if defined(_DEBUG)
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	cout << fixed << setprecision(15);

	for (int i = 0; i < 55; i++)
	{
		columnIters[i] = 0;
		for (int j = 0; j < 55; j++) {
			A[i][j] = 0;
			B[i][j] = false;
		}
	}

	int n, m;

	bool ok = false;
	cin >> n >> m;
	for (int row = 0; row < n; row++)
	{
		cin >> inputStr;
		for (int col = 0; col < m; col++)
		{
			if (inputStr[col] == '#') // черная клетка
				B[row][col] = true;
		}
	}

	set<int> rows;
	set<int> cols;
	set<int> bunishedRows;
	set<int> bunishedCols;
	int iter = 1;
	for (int row = 0; row < n; row++)
	{
		for (int col = 0; col < m; col++)
		{
			if (B[row][col] && bunishedCols.find(col) == bunishedCols.end()) // черная клетка
			{
				cols.insert(col);
				bunishedCols.insert(col);
			}
		}

		//Идем по столбцам, которые отметили и отмечаем строки-пересечения
		for (int col : cols)
		{
			for (int row2 = 0; row2 < n; row2++) {
				if (B[row2][col]) {//Пересечение.
					//Пересечение со строкой, которая уже была использована
					if (bunishedRows.find(row2) != bunishedRows.end() && rows.find(row2) == rows.end())
					{
						cout << "NO";
						return;
					}

					rows.insert(row2);
					bunishedRows.insert(row2);
				}
			}
		}

		//Проверяем, что бы во всех точках пересечения была черная точка
		for (int row2 : rows)
			for (int col2 : cols)
				if (!B[row2][col2]) {
					cout << "NO";
					return;
				}

		rows.clear();
		cols.clear();
	}
	cout << "YES";

}


#include <iostream>
#include <vector>
#include <string>
using namespace std;
string s[51];
vector<int>rr;
int main()
{
	int n, m;
	cin >> n >> m;
	for (int i = 1; i <= n; i++) cin >> s[i];
	for (int j = 1; j <= m; j++)
	{
		rr.clear();
		for (int i = 1; i <= n; i++) if (s[i][j-1] == '#')rr.push_back(i);
		for (int i = 1; i < rr.size(); i++) if (s[rr[i]] != s[rr[i - 1]]) return cout << "No", 0;
	}
	return cout << "Yes", 0;
}


#define _CRT_SECURE_NO_WARNINGS
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <vector>
#include <iomanip>
#include <cstdio>
#include <algorithm>
#include <string>
#define int long long
#define ull  unsigned long long
#define ll long long
#define ll long long
using namespace std;
struct Mystr
{
	int f;
	int s;
	int in;
};
Mystr a1[400000];
Mystr a2[400000];
bool comp1(const Mystr& one, const Mystr& two)
{
	if (one.f == two.f)
	{
		if (one.s == two.s)
		{
			return one.in < two.in;
		}
		return one.s < two.s;
	}
	return  one.f < two.f;
}
char a[1000][1000];
bool visit[1000];
void main()
{
#ifdef _DEBUG
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	int n,m;
	cin >> n >> m;
	for (int i = 0; i < n; i++)
	{
		for (int j = 0; j < m; j++)
		{
			cin >> a[i][j];
		}
	}
	for (int i = 0; i < n; i++)
	{
		for (int j = 0; j < m; j++)
		{
			if (a[i][j] == '#')
			{
				for (int c = 0; c < n; c++)
				{
					if (a[c][j] == '#')
					{
						for (int f = 0; f < m; f++)
						{
							if (a[c][f] != a[i][f])
							{
								cout << "No";
								return;
							}
						}
					}
				}
			}
		}
	}
	cout << "Yes";
}


#include <iostream>
#include <vector>
using namespace std;

string s[51];
vector<int>rr;

int main()
{
	int n, m;
	cin >> n >> m;
	for (int i = 1; i <= n; i++) cin >> s[i];
	for (int j = 1; j <= m; j++)
	{
		rr.clear();
		for (int i = 1; i <= n; i++) if (s[i][j-1] == '#')rr.push_back(i);
		for (int i = 1; i < rr.size(); i++) if (s[rr[i]] != s[rr[i - 1]]) return cout << "No", 0;
	}
	return cout << "Yes", 0;
}


#include<stdio.h>
#include <iostream>
#include <vector>
using namespace std;
string s[51];
vector<int>rr;
int main()
{
	int n, m;
	cin >> n >> m;
	for (int i = 1; i <= n; i++) cin >> s[i];
	for (int j = 1; j <= m; j++)
	{
		rr.clear();
		for (int i = 1; i <= n; i++) if (s[i][j-1] == '#')rr.push_back(i);
		for (int i = 1; i < rr.size(); i++) if (s[rr[i]] != s[rr[i - 1]]) return cout << "No", 0;
	}
	return cout << "Yes", 0;
}


#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include<iostream>
#include<fstream>
#include<cmath>
#include<algorithm>
#include<cstdlib>
#include<queue>
#include<deque>
#include<map>
#include<unordered_map>
#include<string>
#include<stack>
#include<vector>
#include<set>
#include<iomanip>
#include <cmath>
#include <iterator>
#include <cstdint>
#include <list>
#include <memory>
#include <unordered_set>
#include <sstream>
#include <cassert>
#include <set>
#include <algorithm>
#include <numeric>
#include <bitset>
#include <stdio.h>
#include <regex>

#ifdef _DEBUG
constexpr bool debug_mode = true;
#else
constexpr bool debug_mode = false;
#endif

using namespace std;

const double EPS = 1e-9;

typedef unsigned long long ull;
typedef long long ll;

void cexit()
{
	cout << "No";
	exit(0);
}

int main() {
	using GroupItem = pair<string, set<char>>;

	std::ios::sync_with_stdio(false);

	if constexpr (debug_mode) {
		freopen("input.txt", "r", stdin);
		freopen("output.txt", "w", stdout);
	}

	cin.tie(0);
	cout << fixed << setprecision(15);

	int n, m;
	cin >> n >> m;
	vector<vector<char>> arr(n, vector<char>(m));

	for (auto& r : arr)
		for (auto& c : r)
			cin >> c;

	for (int i = 0; i < n; i++)
		for (int j = 0; j < m; j++) {
			if (arr[i][j] != '#')
				continue;

			for (int r = 0; r < n; r++) {
				if (arr[r][j] != '#')
					continue;

				for (int c = 0; c < m; c++) {
					if (arr[r][c] != arr[i][c]) {
						cexit();
					}
				}
			}
		}

	cout << "Yes";

	return 0;
}


#include<iostream>
#include<vector>
#include<string>
#include <unordered_set>
#include <algorithm>
#include <functional>
#include<random>
#define mp(x, y, z) pair<long long, long long> z=make_pair(x, y)
#define pb(x, y) x.push_back(y)
#define ff(x)  if(x>0)
#define cn(x) cin>>x
using namespace std;
typedef  vector<vector<vector<vector<vector<int>>>>> v5nt;
typedef  vector<vector<vector<vector<int>>>> v4nt;
typedef  vector<vector<vector<int>>> v3nt;
typedef long long ll;
typedef pair<int, int> pr;
typedef vector <long long>  vl;
typedef int nt;
#pragma comment(linker, "/STACK:2000000")
vector<vector<int>> matrix;
mt19937 mt(736);
int main()
{
	int n, m, ans=0;
	cin >> n >> m;
	matrix.resize(n);
	for (int i = 0; i<n; i++)
	{
		matrix[i].resize(m);
	}
	for (int i = 0; i < n; i++)
	{
		for (int j = 0; j < m; j++)
		{
			char x;
			cin >> x;
			if (x == '.')
			{
				matrix[i][j] = 0;
			}
			else
			{
				matrix[i][j] = 1;
			}
		}
	}
	for (int i1 = 0; i1 < n; i1++)
	{
		for (nt i2 = i1 + 1; i2 < n; i2++)
		{
			for (int j1 = 0; j1 < m; j1++)
			{
				for (int j2 = j1 + 1; j2 < m; j2++)
				{
					nt cur = matrix[i1][j1] + matrix[i2][j2] + matrix[i1][j2] + matrix[i2][j1];
					if (cur == 3)
					{
						ans++;
					}
				}
			}
		}
	}
	if (ans == 0)
	{
		cout << "Yes";
	}
	else
	{
		cout << "No";
	}
}


#include <iostream>
#include<string.h>
using namespace std;

int main()
{
char a[100][100];
int n,m,i,j,k,jihad=0,ji,ha=0;
cin>>n>>m;
for(i=0;i<n;i++)
     cin>>a[i];
     for(i=0;i<n-1;i++)
        for(j=0;j<m;j++)
     {
         if(a[i][j]=='#')
         {
             for(k=i+1;k<n;k++)
             {
                 ha=0;
                 if(a[k][j]=='#')
                 {
                     for(ji=0;ji<m;ji++)
                    a[i][ji]==a[k][ji]?ha++:ha=-1;
                         if(ha==m)
                        {
                            jihad=0;
                            j=m;
                            break;
                        }
                     else
                         jihad=1;

                 }
             }
         }
         if(jihad==1)
         {
             cout<<"no";
             return 0;
         }
     }
     cout<<"yes";
    return 0;
}


#include <iostream>
#include<string.h>
using namespace std;

int main()
{
char a[50][50];
int n,m,i,j,k,jihad=0,ji,ha=0;
cin>>n>>m;
for(i=0;i<n;i++)
     cin>>a[i];
     for(i=0;i<n;i++)
        for(j=0;j<m;j++)
     {
         if(a[i][j]=='#')
         {
             for(k=i+1;k<n;k++)
             {
                 ha=0;
                 if(a[k][j]=='#')
                 {
                     for(ji=0;ji<m;ji++)
                    a[i][ji]==a[k][ji]?ha++:ha=-1;
                         if(ha==m)
                        {
                            jihad=0;
                            j=m;
                            break;
                        }
                     else
                         jihad=1;

                 }
             }
         }
         if(jihad==1)
         {
             cout<<"no";
             return 0;
         }
     }
     cout<<"yes";
    return 0;
}


#include<iostream>
#include<vector>
#include<cstdio>
#include<algorithm>
#include<set>
#include<map>
#include<iterator>
#include<string>
using namespace std;

typedef long long ll;
typedef double db;
char used1[55], used2[55];
int main(){
	int n, m;
	cin>>n>>m;
	string s[55];
	for(int i=0; i<n; i++)
		cin>>s[i];
	for(int i=0; i<n; i++){
		for(int j=0; j<m; j++){
			if(s[i][j]=='#'){
				vector<int>row, col;
				row.push_back(i);
				col.push_back(j);
				used1[i]=used2[j]=1;
				int ii=0, jj=0;
				while(ii<row.size() || jj<col.size()){
					if(ii<row.size()){
						for(int j1=0; j1<m; j1++){
							if(s[row[ii]][j1]=='#'){
								if(!used2[j1]){
									used2[j1]=1;
									col.push_back(j1);
								}
							}
						}
						ii++;
					}
					if(jj<col.size()){
						for(int i1=0; i1<n; i1++){
							if(s[i1][col[jj]]=='#'){
								if(!used1[i1]){
									used1[i1]=1;
									row.push_back(i1);
								}
							}
						}
						jj++;
					}
				}
				for(ii=0; ii<row.size(); ii++){
					for(int jj=0; jj<col.size(); jj++){
						if(s[row[ii]][col[jj]]=='.'){
							puts("No");
							return 0;
						}
						s[row[ii]][col[jj]]='.';
					}
				}
			}
		}
	}
	puts("Yes");
}


#include<iostream>
#define Maxn 52
using namespace std;

long long row[Maxn];
int n,m;
bool flag = true;

void input(){
    cin>>n>>m;
    char c;
    for (int i = 0; i < n; i++)
        for (int j = 0; j < m; j++){
            cin>>c;
            if (c=='#'){
                row[i] += 1ll<<j;
            }
        }
}

void solve(){
    for (int i = 0; i < n ;i++)
        for (int j = i+1; j < n; j++)
            if (((row[i] & row[j]) > 0)&&(row[i]!=row[j])){
                flag = false;
                return;
            }
}

void output(){
    if (flag) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}

int main(){
    input();
    solve();
    output();
}


#include<iostream>
#define Maxn 52
using namespace std;

long long row[Maxn];
int n,m;
bool flag = true;

void input(){
    cin>>n>>m;
    char c;
    for (int i = 0; i < n; i++)
        for (int j = 0; j < m; j++){
            cin>>c;
            if (c=='#'){
                row[i] += 1<<j;
            }
        }
}

void solve(){
    for (int i = 0; i < n ;i++)
        for (int j = i+1; j < n; j++)
            if (((row[i] & row[j]) > 0)&&(row[i]!=row[j])){
                flag = false;
                return;
            }
}

void output(){
    if (flag) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}

int main(){
    input();
    solve();
    output();
}


#pragma comment(linker, "/STACK:250000000")
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <string>
#include <ctime>
#include <cassert>
#include <memory.h>
#include <fstream>
#include <bitset>
#include <algorithm>
#include <cmath>

//#include <unordered_map>

#define forn(i, n) for (int i = 0; i < int(n); i++)
#define for1(i, n) for (int i = 1; i < int(n); i++)
#define nfor(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define forr(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define fore(i, l, r) for (int i = int(l); i < int(r); i++)
#define forft(i, l, r) for (int i = int(l); i < int(r); i++)
#define correct(x, y, n, m) (0 <= (x) && (x) < (n) && 0 <= (y) && (y) < (m))
#define all(a) (a).begin(), (a).end()
#define sz(a) int((a).size())
#define pb(a) push_back(a)
#define mp(x, y) make_pair((x), (y))
#define ms(a, v) memset(a, v, sizeof(a))
#define x first
#define y second
#define X first
#define Y second
#define ft first
#define sc second

using namespace std;

typedef long long li;
typedef long double ld;
typedef pair<int, int> pt;

template<typename X> inline X abs(const X& a) { return a < 0? -a: a; }
template<typename X> inline X sqr(const X& a) { return a * a; }

const int INF = int(1e9);
const li INF64 = li(4e18);
const ld EPS = 1e-9, PI = 3.1415926535897932384626433832795;

const int N = 55;
int n, m;
string a[N];
int used_rows[N], used_cols[N];

bool read() {
	cin >> n >> m;

	forn(i, n) {
		cin >> a[i];
	}

	return true;
}

void solve() {
	forn(i, n) {
		if (used_rows[i]) {
			continue;
		}

		vector<int> cols;
		forn(j, m) {
			if (a[i][j] == '#') {
				cols.pb(j);
			}
		}

		if (sz(cols) == 0) {
			continue;
		}

		forn(j, sz(cols)) {
			used_cols[cols[j]] = 1;
		}
		used_rows[i] = 1;

		forft(i2, i + 1, n) {
			bool ok = false;
			forn(j, m) {
				if (a[i2][j] == '#' && used_cols[j] == 1) {
					ok = true;
				}
			}

			if (!ok) {
				continue;
			}

			forn(j, m) {
				if (a[i2][j] == '#' && used_cols[j] != 1) {
					cout << "No" << endl;
					return;
				}
			}
			used_rows[i2] = true;
		}

		forn(j, sz(cols)) {
			used_cols[cols[j]] = 2;
		}
	}

	cout << "Yes" << endl;
}

//#define FILES

int main() {
#ifdef AR
	assert(freopen("input.txt", "rt", stdin));
	assert(freopen("output.txt", "wt", stdout));
#else
#ifdef FILES
	assert(freopen(".in", "rt", stdin));
	assert(freopen(".out", "wt", stdout));
#endif
#endif

	srand(time(NULL));

	cout << setprecision(10) << fixed;
	cerr << setprecision(10) << fixed;

	read();
	solve();

#ifdef AR
	cerr << "Time: " << clock() << endl;
#endif
	return 0;
}


#pragma comment(linker, "/STACK:250000000")
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <string>
#include <ctime>
#include <cassert>
#include <memory.h>
#include <fstream>
#include <bitset>
#include <algorithm>
#include <cmath>

//#include <unordered_map>

#define forn(i, n) for (int i = 0; i < int(n); i++)
#define for1(i, n) for (int i = 1; i < int(n); i++)
#define nfor(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define forr(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define fore(i, l, r) for (int i = int(l); i < int(r); i++)
#define forft(i, l, r) for (int i = int(l); i < int(r); i++)
#define correct(x, y, n, m) (0 <= (x) && (x) < (n) && 0 <= (y) && (y) < (m))
#define all(a) (a).begin(), (a).end()
#define sz(a) int((a).size())
#define pb(a) push_back(a)
#define mp(x, y) make_pair((x), (y))
#define ms(a, v) memset(a, v, sizeof(a))
#define x first
#define y second
#define X first
#define Y second
#define ft first
#define sc second

using namespace std;

typedef long long li;
typedef long double ld;
typedef pair<int, int> pt;

template<typename X> inline X abs(const X& a) { return a < 0? -a: a; }
template<typename X> inline X sqr(const X& a) { return a * a; }

const int INF = int(1e9);
const li INF64 = li(4e18);
const ld EPS = 1e-9, PI = 3.1415926535897932384626433832795;

const int N = 55;
int n, m;
string a[N];
int used_rows[N], used_cols[N];

bool read() {
	cin >> n >> m;

	forn(i, n) {
		cin >> a[i];
	}

	return true;
}

void solve() {
	forn(i, n) {
		if (used_rows[i]) {
			continue;
		}

		vector<int> cols;
		forn(j, m) {
			if (a[i][j] == '#') {
				cols.pb(j);
			}
		}

		if (sz(cols) == 0) {
			continue;
		}

		forn(j, sz(cols)) {
			used_cols[cols[j]] = 1;
		}
		used_rows[i] = 1;

		forft(i2, i + 1, n) {
			bool ok = false;
			forn(j, m) {
				if (a[i2][j] == '#' && used_cols[j] == 1) {
					ok = true;
				}
			}

			if (!ok) {
				continue;
			}

			forn(j, m) {
				if (a[i2][j] == '#' && used_cols[j] != 1 || a[i2][j] == '.' && used_cols[j] == 1) {
					cout << "No" << endl;
					return;
				}
			}
			used_rows[i2] = 1;
		}

		forn(j, sz(cols)) {
			used_cols[cols[j]] = 2;
		}
	}

	cout << "Yes" << endl;
}

//#define FILES

int main() {
#ifdef AR
	assert(freopen("input.txt", "rt", stdin));
	assert(freopen("output.txt", "wt", stdout));
#else
#ifdef FILES
	assert(freopen(".in", "rt", stdin));
	assert(freopen(".out", "wt", stdout));
#endif
#endif

	srand(time(NULL));

	cout << setprecision(10) << fixed;
	cerr << setprecision(10) << fixed;

	read();
	solve();

#ifdef AR
	cerr << "Time: " << clock() << endl;
#endif
	return 0;
}


#include <cstdio>
#include <set>
#include <iostream>
#include <string>
#include <ctime>
#include <cstdlib>
#include <map>
#include <vector>

using namespace std;

bool check_vec(vector<int> &a, vector<int> &b)
{
    if (a.size() != b.size())
        return false;
    for (int i = 0; i < a.size(); i++)
        if (a[i] != b[i])
            return false;
    return true;
}

int main()
{
    int n, m;
    scanf("%d%d", &n, &m);
    char **mas = new char*[n];
    for (int i = 0; i < n; i++) {
        mas[i] = new char[m + 1];
        scanf("%s", mas[i]);
    }
    vector<int> *row = new vector<int>[n], *col = new vector<int>[m];
    for (int i = 0; i < n; i++)
        for (int j = 0; j < m; j++)
            if (mas[i][j] == '#')
                row[i].push_back(j);
    for (int j = 0; j < m; j++)
        for (int i = 0; i < n; i++)
            if (mas[i][j] == '#')
                col[j].push_back(i);
    for (int i = 0; i < n; i++) {
        for (int j = 1; j < row[i].size(); j++)
            if (!check_vec(col[row[i][j - 1]], col[row[i][j]])) {
                printf("No\n");
                return false;
            }
    }
    for (int j = 0; j < m; j++) {
        for (int i = 1; i < col[j].size(); i++)
            if (!check_vec(row[col[j][i - 1]], row[col[j][i]])) {
                printf("No\n");
                return false;
            }
    }
    printf("Yes\n");
    return 0;
}


#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#define fo(i,x,y) for(int i=x; i<y; ++i)
#define of(i,x,y) for(int i=x; i>=y; --i)
#define mii map<int,int>
#define mll map<long long,long long>
#define msi map<string,int>
#define mmii multimap<int,int>
#define mmll multimap<long long,long long>
#define mmsi multimap<string,int>
#define si set<int>
#define sll set<long long>
#define ssi multiset<int>
#define ssl multiset<long long>
#define sci(x) scanf("%i",&x)
#define scl scanf("\n")
#define scll(x) scanf("%I64d",&x)
#define scd(x) scanf("%d",&x)
#define X first
#define Y second
#define pb push_back
#define mp make_pair
#include<stdio.h>
#include<iostream>
#include<map>
#include<unordered_map>
#include<unordered_set>
#include<vector>
#include<set>
#include<math.h>
#include<deque>
#include<cmath>
#include<algorithm>
#include<string>
#include<string.h>
#include<time.h>
#include<queue>
typedef long long ll;
using namespace std;

int n, m;
string a[100];
bool b[100];

int main() {

	cin.sync_with_stdio(false);
	cin >> n >> m;
	fo(i, 0, n) {
		cin >> a[i];
	}
	fo(i, 0, n) {
		if (!b[i]) {
			fo(j, 0, n) {
				if (!b[j] && a[i] == a[j]) {
					b[j] = true;
				}
 			}
			fo(j, 0, m) {
				if (a[i][j] == '#') {
					fo(k, 0, n) {
						if (a[k][j] == '#' && !b[k]) {
							cout << "No";
							return 0;
						}
					}
				}
			}
		}
	}
	cout << "Yes";
	return 0;

}


#include "stdafx.h"

#define _CRT_SECURE_NO_WARNINGS

#include <iostream>
#include <set>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;
const int N = 255;

int parent[N];
int ra[N];
void make_set(int v) {
	parent[v] = v;
	ra[v] = 0;
}

int find_set(int v) {
	if (v == parent[v])
		return v;
	return parent[v] = find_set(parent[v]);
}

void union_sets(int a, int b) {
	a = find_set(a);
	b = find_set(b);
	if (a != b) {
		if (ra[a] < ra[b])
			swap(a, b);
		parent[b] = a;
		if (ra[a] == ra[b])
			++ra[a];
	}
}
string s[N];
int main()
{
#if _DEBUG
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	cout.sync_with_stdio(false);
	cin.tie(0);

	int n, m;
	cin >> n >> m;
	for (int i = 0; i < n; i++) {
		cin >> s[i];
	}
	for (int i = 0; i < n; i++)
		make_set(i);
	for (int j = 0; j < m; j++)
		make_set(100 + j);

	for (int i = 0; i < n; i++) {
		for (int j = 0; j < m; j++) {
			if (s[i][j] == '#') {
				union_sets(i, 100 + j);
			}
		}
	}

	for (int i = 0; i < n; i++) {
		for (int j = 0; j < m; j++) {
			if (s[i][j] == '#' && find_set(i) != find_set(100 + j)) {
				cout << "No";
				return 0;
			}
			if (s[i][j] != '#' && find_set(i) == find_set(100 + j)) {
				cout << "No";
				return 0;
			}
		}
	}
	cout << "Yes";
	return 0;
}


#define _CRT_SECURE_NO_WARNINGS

#include <iostream>
#include <set>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;
const int N = 255;

int parent[N];
int ra[N];
void make_set(int v) {
	parent[v] = v;
	ra[v] = 0;
}

int find_set(int v) {
	if (v == parent[v])
		return v;
	return parent[v] = find_set(parent[v]);
}

void union_sets(int a, int b) {
	a = find_set(a);
	b = find_set(b);
	if (a != b) {
		if (ra[a] < ra[b])
			swap(a, b);
		parent[b] = a;
		if (ra[a] == ra[b])
			++ra[a];
	}
}
string s[N];
int main()
{
#if _DEBUG
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	cout.sync_with_stdio(false);
	cin.tie(0);

	int n, m;
	cin >> n >> m;
	for (int i = 0; i < n; i++) {
		cin >> s[i];
	}
	for (int i = 0; i < n; i++)
		make_set(i);
	for (int j = 0; j < m; j++)
		make_set(100 + j);

	for (int i = 0; i < n; i++) {
		for (int j = 0; j < m; j++) {
			if (s[i][j] == '#') {
				union_sets(i, 100 + j);
			}
		}
	}

	for (int i = 0; i < n; i++) {
		for (int j = 0; j < m; j++) {
			if (s[i][j] == '#' && find_set(i) != find_set(100 + j)) {
				cout << "No";
				return 0;
			}
			if (s[i][j] != '#' && find_set(i) == find_set(100 + j)) {
				cout << "No";
				return 0;
			}
		}
	}
	cout << "Yes";
	return 0;
}


#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
using namespace std;

int T,a,n,p,h,i,j,k,ans;

int cal(int x,int y,int z)
{
	if((long long)x*y<z)
	{
		if(z==p)return x;
		else return max(x,z-x*y);
	}
	int tmp=(long long)x*y/z+((long long)x*y%z!=0);
	if((long long)x*y%z+x<=z/x*x)--tmp;
	return cal(x-z%x,tmp-1,x);
}

int main()
{
	scanf("%d",&T);
	for(;T;--T)
	{
		scanf("%d%d%d%d",&a,&n,&p,&h);
		if(cal(a%p,n,p)<=h)printf("YES\n");
		else printf("NO\n");
	}
}


#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
using namespace std;

int T,a,n,p,h,i,j,k,ans;

int cal(int x,int y,int z)
{
	if(!y)return x;
	if((long long)x*y<z)
	{
		if(z==p)return x;
		else return max(x,z-x*y);
	}
	int tmp=(long long)x*y/z+((long long)x*y%z!=0);
	if((long long)x*y%z+x<=z/x*x)--tmp;
	return cal(x-z%x,tmp-1,x);
}

int main()
{
	scanf("%d",&T);
	for(;T;--T)
	{
		scanf("%d%d%d%d",&a,&n,&p,&h);
		if(cal(a%p,n,p)<=h)printf("YES\n");
		else printf("NO\n");
	}
}


#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
using namespace std;

int T,a,n,p,h,i,j,k,ans;

int cal(int x,int y,int z)
{
	if((long long)x*y<z)
	{
		if(z==p)return x;
		else return max(x,z-x*y);
	}
	int tmp=(long long)x*y/z;
	if((long long)x*y%z+x<=z/x*x)--tmp;
	return cal(x-z%x,tmp,x);
}

int main()
{
	scanf("%d",&T);
	for(;T;--T)
	{
		scanf("%d%d%d%d",&a,&n,&p,&h);
		if(cal(a%p,n,p)<=h)printf("YES\n");
		else printf("NO\n");
	}
}


#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
using namespace std;

int T,a,n,p,h,i,j,k,ans;

int cal(int x,int y,int z)
{
	if(!y)return z;
	if((long long)x*y<z)
	{
		if(z==p)return x;
		else return max(x,z-x*y);
	}
	int tmp=(long long)x*y/z+((long long)x*y%z!=0);
	if((long long)x*y%z+x<=z/x*x)--tmp;
	return cal(x-z%x,tmp-1,x);
}

int main()
{
	scanf("%d",&T);
	for(;T;--T)
	{
		scanf("%d%d%d%d",&a,&n,&p,&h);
		if(cal(a%p,n,p)<=h)printf("YES\n");
		else printf("NO\n");
	}
}


#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
using namespace std;

int T,a,n,p,h,i,j,k,ans;

int cal(int x,int y,int z)
{
	if(!y)return 0;
	if((long long)x*y<z)
	{
		if(z==p)return x;
		else return max(x,z-x*y);
	}
	int tmp=(long long)x*y/z+((long long)x*y%z!=0);
	if((long long)x*y%z+x<z/x*x)--tmp;
	return cal(x-z%x,tmp-1,x);
}

int main()
{
	scanf("%d",&T);
	for(;T;--T)
	{
		scanf("%d%d%d%d",&a,&n,&p,&h);
		if(cal(a%p,n,p)<=h)printf("YES\n");
		else printf("NO\n");
	}
}


#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
using namespace std;

int T,a,n,p,h,i,j,k,ans;

int cal(int x,int y,int z)
{
	if(!y)return 0;
	if((long long)x*y<z)
	{
		if(z==p)return x;
		else return max(x,z-x*y);
	}
	int tmp=(long long)x*y/z;
	if((long long)x*y%z+x<z/x*x)--tmp;
	return cal(x-z%x,tmp,x);
}

int main()
{
	scanf("%d",&T);
	for(;T;--T)
	{
		scanf("%d%d%d%d",&a,&n,&p,&h);
		if(cal(a%p,n,p)<=h)printf("YES\n");
		else printf("NO\n");
	}
}


#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
using namespace std;

int T,a,n,p,h,i,j,k,ans;

int cal(int x,int y,int z)
{
	if(!y)return 0;
	if((long long)x*y<z)
	{
		if(z==p)return x;
		else return max(x,z-x*y);
	}
	int tmp=(long long)x*y/z+((long long)x*y%z!=0);
	if((long long)x*y%z+x<=z/x*x)--tmp;
	return cal(x-z%x,tmp-1,x);
}

int main()
{
	scanf("%d",&T);
	for(;T;--T)
	{
		scanf("%d%d%d%d",&a,&n,&p,&h);
		if(cal(a%p,n,p)<=h)printf("YES\n");
		else printf("NO\n");
	}
}


#include <stdio.h>
#include <vector>

#define pb push_back
#define ll long long

using namespace std;

struct fourtuple {
   ll a, b, c, d;
};

vector<fourtuple> Euclid(ll x, ll y) {
   vector<fourtuple> res;

   if(x < y) return Euclid(y,x);

   fourtuple F;
   F.c = 0;
   F.d = 0;

   while(y >= 1) {
      F.a = x;
      F.b = y;
      res.pb(F);

      ll tmp = y;
      y = (x % y);
      x = tmp;
   }

   res[res.size() - 1].c = 1;
   res[res.size() - 1].d = -res[res.size() - 1].a + 1;

   for(int i = res.size() - 2; i >= 0; i--) {
      ll k = res[i].a/res[i].b;
      res[i].c = res[i+1].d;
      res[i].d = res[i+1].c - k*res[i+1].d;

      ll r = ((res[i].c % res[i].b) + res[i].b) % res[i].b;
      ll s = (res[i].c - r)/ res[i].b;
      res[i].c = r;
      res[i].d += s * res[i].a;
   }

   return res;
}

void Solve(ll a, ll n, ll p, ll h) {
   if(h >= a) {
      printf("YES\n");
      return;
   }
   if(h == 0) {
      printf("NO\n");
      return;
   }

   vector<fourtuple> eucl = Euclid(p, a);

   ll r = 1, s = 0;

   int i;

   for(i = 1; eucl[i].b > h; i++) {
      ll k = eucl[i-1].a / eucl[i-1].b;
      ll tmp = s;
      s = r;
      r = k*r + tmp;
   }

   ll k = eucl[i-1].a / eucl[i-1].b;
   ll tmp = s;
   s = r;
   r = k*r + tmp;

   k = (eucl[i].a - h)/eucl[i].b;
   if(eucl[i].a - k*eucl[i].b > h) k++;

   ll b = eucl[i].b;
   a = eucl[i].a - k * eucl[i].b;
   s += k*r;

   if(a < b) {
      tmp = a;
      a = b;
       b = tmp;
      tmp = s;
      s = r;
      r = tmp;
   }

   if(r + s - 1 <= n) printf("YES\n");
   else printf("NO\n");
}

int main() {
   int t;
   scanf("%d", &t);

   while(t > 0) {
      ll a, n, p, h;
      scanf("%I64d%I64d%I64d%I64d", &a, &n, &p, &h);
      Solve(a,n,p,h);
      t--;
   }

   getchar();
   getchar();
   return 0;
}


#include <stdio.h>
#include <vector>

#define pb push_back
#define ll long long

using namespace std;

struct fourtuple {
   ll a, b, c, d;
};

vector<fourtuple> Euclid(ll x, ll y) {
   vector<fourtuple> res;

   if(x < y) return Euclid(y,x);

   fourtuple F;
   F.c = 0;
   F.d = 0;

   while(y >= 1) {
      F.a = x;
      F.b = y;
      res.pb(F);

      ll tmp = y;
      y = (x % y);
      x = tmp;
   }

   res[res.size() - 1].c = 1;
   res[res.size() - 1].d = -res[res.size() - 1].a + 1;

   for(int i = res.size() - 2; i >= 0; i--) {
      ll k = res[i].a/res[i].b;
      res[i].c = res[i+1].d;
      res[i].d = res[i+1].c - k*res[i+1].d;

      ll r = ((res[i].c % res[i].b) + res[i].b) % res[i].b;
      ll s = (res[i].c - r)/ res[i].b;
      res[i].c = r;
      res[i].d += s * res[i].a;
   }

   return res;
}

void Solve(ll a, ll n, ll p, ll h) {
   if(h >= a) {
      printf("YES\n");
      return;
   }

   vector<fourtuple> eucl = Euclid(p, a);

   ll r = 1, s = 0;

   int i;

   for(i = 1; eucl[i].b > h; i++) {
      ll k = eucl[i-1].a / eucl[i-1].b;
      ll tmp = s;
      s = r;
      r = k*r + tmp;
   }

   ll k = eucl[i-1].a / eucl[i-1].b;
   ll tmp = s;
   s = r;
   r = k*r + tmp;

   k = (eucl[i].a - h)/eucl[i].b;
   if(eucl[i].a - k*eucl[i].b > h) k++;

   ll b = eucl[i].b;
   a = eucl[i].a - k * eucl[i].b;
   s += k*r;

   if(a < b) {
      tmp = a;
      a = b;
       b = tmp;
      tmp = s;
      s = r;
      r = tmp;
   }

   if(r + s - 1 <= n) printf("YES\n");
   else printf("NO\n");
}

int main() {
   int t;
   scanf("%d", &t);

   while(t > 0) {
      ll a, n, p, h;
      scanf("%I64d%I64d%I64d%I64d", &a, &n, &p, &h);
      Solve(a,n,p,h);
      t--;
   }

   getchar();
   getchar();
   return 0;
}


#include <stdio.h>
#include <vector>

#define pb push_back
#define ll long long

using namespace std;

struct fourtuple {
   ll a, b, c, d;
};

vector<fourtuple> Euclid(ll x, ll y) {
   vector<fourtuple> res;

   if(x < y) return Euclid(y,x);

   fourtuple F;
   F.c = 0;
   F.d = 0;

   while(y >= 1) {
      //printf("E %I64d %I64d\n", x, y);
      F.a = x;
      F.b = y;
      res.pb(F);

      ll tmp = y;
      y = (x % y);
      x = tmp;
   }

   res[res.size() - 1].c = 1;
   res[res.size() - 1].d = -res[res.size() - 1].a + 1;

   for(int i = res.size() - 2; i >= 0; i--) {
      ll k = res[i].a/res[i].b;
      res[i].c = res[i+1].d;
      res[i].d = res[i+1].c - k*res[i+1].d;

      ll r = ((res[i].c % res[i].b) + res[i].b) % res[i].b;
      ll s = (res[i].c - r)/ res[i].b;
      res[i].c = r;
      res[i].d += s * res[i].a;
   }

   return res;
}

void Solve(ll a, ll n, ll p, ll h) {
   if(h >= a) {
      printf("YES\n");
      return;
   }
   if(h == 0) {
      printf("NO\n");
      return;
   }

   vector<fourtuple> eucl = Euclid(p, a);

   ll r = 1, s = 0;

   int i;

   for(i = 1; eucl[i].b > h; i++) {
      ll k = eucl[i-1].a / eucl[i-1].b;
      ll tmp = s;
      s = r;
      r = k*r + tmp;
   }

   ll k = eucl[i-1].a / eucl[i-1].b;
   ll tmp = s;
   s = r;
   r = k*r + tmp;

   //printf(">> %I64d %I64d %I64d %I64d\n", eucl[i].a, eucl[i].b, r, s);

   k = (eucl[i].a - h)/eucl[i].b;
   if(eucl[i].a - k*eucl[i].b > h) k++;

   ll b = eucl[i].b;
   a = eucl[i].a - k * eucl[i].b;
   s += k*r;

   if(a < b) {
      tmp = a;
      a = b;
       b = tmp;
      tmp = s;
      s = r;
      r = tmp;
   }

   //printf(">> %I64d %I64d %I64d %I64d\n", a, b, r, s);

   if(r + s - 1 <= n) printf("YES\n");
   else printf("NO\n");
}

int main() {
   int t;
   scanf("%d", &t);

   while(t > 0) {
      ll a, n, p, h;
      scanf("%I64d%I64d%I64d%I64d", &a, &n, &p, &h);

      a = a % p;
      Solve(a,n,p,h);
      t--;
   }

   getchar();
   getchar();
   return 0;
}


#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;

typedef long long ll;

int MAX(int a, int n, int p, bool first=true)
{
	if ((ll)a*n<p) return first?a:max(a,p-a*n);
	return MAX(min(p%a,a-p%a),(ll)a*n/p-((ll)a*n%p<p/a*a-a),a,false);
}

int main()
{
	int T;
	for (scanf("%d",&T);T;T--)
	{
		int a, n, p, h;
		scanf("%d%d%d%d",&a,&n,&p,&h);
		puts(MAX(a%p,n,p)<=h?"YES":"NO");
	}
	return 0;
}


#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;

int MAX(int a, int n, int p)
{
	if ((long long)a*n<p) return max(a,p-a*n);
	return MAX(min(p%a,a-p%a),(long long)a*n/p-(a*n%p<p/a*a-a),a);
}

int main()
{
	int T;
	for (scanf("%d",&T);T;T--)
	{
		int a, n, p, h;
		scanf("%d%d%d%d",&a,&n,&p,&h);
		puts(MAX(a,n,p)<=h?"YES":"NO");
	}
	return 0;
}


typedef long long ll;
ll x,y;
int maxdis(ll x,ll n,ll s){
	if (x>(s>>1))
		x=s-x;
	if (x*n>s)
		return maxdis(s % x,(x*n+s % x)/s, x);
	else
		return (x>(s-x*(n-1))?x:(s-x*(n-1)));
}
#include <iostream>
int a,n,p,h;
int main(){
	int t;
	using namespace std;
	ios::sync_with_stdio (false);
	cin>>t;
	for (register int i=0;i<t;i++){
		cin>>a>>n>>p>>h,a%=p;
		int maxd=((ll)a*n<p)?a:maxdis (a%p, n+1, p);
		if (maxd<=h)
			cout<<"YES\n";
		else
			cout<<"NO\n";
	}
	return 0;
}


typedef long long ll;
ll x,y;
int maxdis(ll x,ll n,ll s){
	if (x>(s>>1))
		x=s-x;
	if (x*n>s)
		return maxdis(s % x,(x*n+s % x)/s, x);
	else
		return (x>(s-x*(n-1))?x:(s-x*(n-1)));
}
#include <iostream>
int a,n,p,h;
int main(){
	int t;
	using namespace std;
	ios::sync_with_stdio (false);
	cin>>t;
	for (register int i=0; i<t; i++){
		cin>>a>>n>>p>>h;
		a=a % p;
		int maxd=((ll)a*n<p)?a:maxdis(a%p, n+1, p);
		if (maxd<=h)
			cout<<"YES\n";
		else
			cout<<"NO\n"
	}
	return 0;
}


#include <bits/stdc++.h>
using namespace std;

typedef long long ll;

ll calc(ll a, ll n, ll p)
{
    return a * n < p ? max(a, p - a * n) : calc(a - p % a, a * n / p - (a * n % p < a * (p / a - 1)), a);
}

int main()
{
    ios::sync_with_stdio(0);
    int T; cin >> T;
    while (T--) {
        ll a, n, p, h;
        cin >> a >> n >> p >> h;
        if ((a * n < p ? a : calc(a, n, p)) > h)
            cout << "NO\n";
        else
            cout << "YES\n";
    }
}


#include <bits/stdc++.h>
using namespace std;

typedef long long ll;

ll calc(ll a, ll n, ll p)
{
    return a * n < p ? max(a, p - a * n) : calc(a - p % a, a * n / p - (a * n % p < a * (p / a - 1)), a);
}

int main()
{
    ios::sync_with_stdio(0);
    int T; cin >> T;
    while (T--) {
        ll a, n, p, h;
        cin >> a >> n >> p >> h;
        a %= p;
        if ((a * n < p ? a : calc(a, n, p)) > h)
            cout << "NO\n";
        else
            cout << "YES\n";
    }
}


#include <bits/stdc++.h>
using namespace std;

typedef long long ll;

ll calc(ll a, ll n, ll p)
{
    ll m = a * n / p;
    if (!m)
        return max(a, p - a * n);
    if (a * n % p < (p / a - 1) * a)
        --m;
    return m ? calc(min(p % a, p - p % a), m, a) : a;
}

int main()
{
    ios::sync_with_stdio(0);
    int T; cin >> T;
    while (T--) {
        ll a, n, p, h;
        cin >> a >> n >> p >> h;
        a %= p;
        if ((a * n < p ? a : calc(a, n, p)) > h)
            cout << "NO\n";
        else
            cout << "YES\n";
    }
}


#include <bits/stdc++.h>

#define inf 0x3f3f3f3f

#define MOD 1000000007

#define pb push_back

#define sq(x) ((x)*(x))

#define x first

#define y second

#define eps 1e-8

#define bpt(x) (__builtin_popcount(x))

#define bptl(x) (__builtin_popcountll(x))

#define bit(x, y) (((x)>>(y))&1)

#define bclz(x) (__builtin_clz(x))

#define bclzl(x) (__builtin_clzll(x))

#define bctz(x) (__builtin_ctz(x))

#define bctzl(x) (__builtin_ctzll(x))

#define debug(x) cout << #x << " = " << x << endl

#define PQ priority_queue<pii, vector<pii>, greater<pii> >

using namespace std;

typedef long long INT;

typedef vector<int> VI;

typedef pair<int, int> pii;

typedef pair<pii, int> pi3;

typedef double DO;

template<typename T, typename U> inline void smin(T &a, U b) {if (a>b) a=b;}

template<typename T, typename U> inline void smax(T &a, U b) {if (a<b) a=b;}

INT calc(INT a, INT n, INT p) {

	INT k=a*n/p;

	if (!k) return max(a, p-a*n);

	if (a*n%p<p/a*a-a) k--;

	return calc(min(a-p%a, p%a), k, a);

}

int main() {

	int T;

	INT a, n, h, p;

	for (scanf("%d", &T); T--; ) {

		scanf("%I64d%I64d%I64d%I64d", &a, &n, &p, &h);

		if (a*n<=p) {

			if (a<=h) puts("YES");

			else puts("NO");

		} else if (calc(a, n, p)<=h) puts("YES");

		else puts("NO");

	}

	return 0;

}


#include <bits/stdc++.h>

#define inf 0x3f3f3f3f

#define MOD 1000000007

#define pb push_back

#define sq(x) ((x)*(x))

#define x first

#define y second

#define eps 1e-8

#define bpt(x) (__builtin_popcount(x))

#define bptl(x) (__builtin_popcountll(x))

#define bit(x, y) (((x)>>(y))&1)

#define bclz(x) (__builtin_clz(x))

#define bclzl(x) (__builtin_clzll(x))

#define bctz(x) (__builtin_ctz(x))

#define bctzl(x) (__builtin_ctzll(x))

#define debug(x) cout << #x << " = " << x << endl

#define PQ priority_queue<pii, vector<pii>, greater<pii> >

using namespace std;

typedef long long INT;

typedef vector<int> VI;

typedef pair<int, int> pii;

typedef pair<pii, int> pi3;

typedef double DO;

template<typename T, typename U> inline void smin(T &a, U b) {if (a>b) a=b;}

template<typename T, typename U> inline void smax(T &a, U b) {if (a<b) a=b;}

INT calc(INT a, INT n, INT p) {

	INT k=a*n/p;

	if (!k) return max(a, p-a*n);

	if (a*n%p<p/a*a-a) k--;

	return calc(min(a-p%a, p%a), k, a);

}

int main() {

	int T;

	INT a, n, h, p;

	for (scanf("%d", &T); T--; ) {

		scanf("%I64d%I64d%I64d%I64d", &a, &n, &p, &h);

		a%=p;

		if (a*n<=p) {

			if (a<=h) puts("YES");

			else puts("NO");

		} else if (calc(a, n, p)<=h) puts("YES");

		else puts("NO");

	}

	return 0;

}


#include <bits/stdc++.h>

#define inf 0x3f3f3f3f

#define MOD 1000000007

#define pb push_back

#define sq(x) ((x)*(x))

#define x first

#define y second

#define eps 1e-8

#define bpt(x) (__builtin_popcount(x))

#define bptl(x) (__builtin_popcountll(x))

#define bit(x, y) (((x)>>(y))&1)

#define bclz(x) (__builtin_clz(x))

#define bclzl(x) (__builtin_clzll(x))

#define bctz(x) (__builtin_ctz(x))

#define bctzl(x) (__builtin_ctzll(x))

#define debug(x) cout << #x << " = " << x << endl

#define PQ priority_queue<pii, vector<pii>, greater<pii> >

using namespace std;

typedef long long INT;

typedef vector<int> VI;

typedef pair<int, int> pii;

typedef pair<pii, int> pi3;

typedef double DO;

template<typename T, typename U> inline void smin(T &a, U b) {if (a>b) a=b;}

template<typename T, typename U> inline void smax(T &a, U b) {if (a<b) a=b;}

INT calc(INT a, INT n, INT p) {

	INT k=a*n/p;

	if (!k) return max(a, p-a*n);

	if (a*n%p<p/a*a-a) k--;

	return calc(min(a-p%a, p%a), k, a);

}

int main() {

	int T;

	INT a, n, h, p;

	for (scanf("%d", &T); T--; ) {

		scanf("%I64d%I64d%I64d%I64d", &a, &n, &h, &p);

		if (a*n<=p) {

			if (a<=h) puts("YES");

			else puts("NO");

		} else if (calc(a, n, p)<=h) puts("YES");

		else puts("NO");

	}

	return 0;

}


/**
 *    author:  enot.1.10, Vladimir Smykalov (enot.1.10@gmail.com)
 *    created: 24.07.2015 16:13:05
**/
#include <bits/stdc++.h>

#define forn(i, n) for(int i = 0 ; (i) < (n) ; ++i)
#define eprintf(...) fprintf(stderr, __VA_ARGS__),fflush(stderr)

using namespace std;

typedef long long ll;
typedef double dbl;

const int inf = (int)1.01e9;
const dbl eps = 1e-9;

/** --- main part --- **/

#define TASK "a"

void myAssert()
{
    int cnt = 0;
    while (1)
    {
        cnt += 1;
    }
}

bool go(int a, int n, int p, int h)
{
    if (h == 0) return false;
    if (a == 0) myAssert();
    //if (a * 2 > p) return go(p - a, n, p, h);
    if (p <= h) return true;
    if (n < p / a) return p - n * a <= h;
    if (a == 1) return true;
    int a1 = p % a;
    int T = n / (p / a) - 1;
    int n1 = ((T + 1) * (ll)a - 1) / (a + a1);
    return go(a1, n1, a, h);
}

int main()
{
    #ifdef home
        assert(freopen(TASK".in", "r", stdin));
        assert(freopen(TASK".out", "w", stdout));
    #endif
    int tn;
    scanf("%d", &tn);
    forn(tt, tn)
    {
        int a, n, p, h;
        scanf("%d%d%d%d", &a, &n, &p, &h);
        bool res = go(a % p, n, p, h);
        if (res) printf("YES\n");
        else printf("NO\n");
    }
    #ifdef home
        eprintf("Time: %d ms\n", (int)(clock() * 1000. / CLOCKS_PER_SEC));
    #endif
    return 0;
}


/**
 *    author:  enot.1.10, Vladimir Smykalov (enot.1.10@gmail.com)
 *    created: 24.07.2015 16:13:05
**/
#include <bits/stdc++.h>

#define forn(i, n) for(int i = 0 ; (i) < (n) ; ++i)
#define eprintf(...) fprintf(stderr, __VA_ARGS__),fflush(stderr)

using namespace std;

typedef long long ll;
typedef double dbl;

const int inf = (int)1.01e9;
const dbl eps = 1e-9;

/** --- main part --- **/

#define TASK "a"

bool go(int a, int n, int p, int h)
{
    if (h == 0) return false;
    //if (a * 2 < p) return go(p - a, n, p, h);
    if (p <= h) return true;
    if (n < p / a) return p - n * a <= h;
    if (a == 1) return true;
    int a1 = p % a;
    int n1 = ((n + 1) * (ll)a - p + a1 - 1) / p;
    return go(a1, n1, a, h);
}

int main()
{
    #ifdef home
        assert(freopen(TASK".in", "r", stdin));
        assert(freopen(TASK".out", "w", stdout));
    #endif
    int tn;
    scanf("%d", &tn);
    forn(tt, tn)
    {
        int a, n, p, h;
        scanf("%d%d%d%d", &a, &n, &p, &h);
        a = a % p;
        bool res;
        if (n < p / a) res = a <= h;
        else res = go(a % p, n, p, h);
        if (res) printf("YES\n");
        else printf("NO\n");
    }
    #ifdef home
        eprintf("Time: %d ms\n", (int)(clock() * 1000. / CLOCKS_PER_SEC));
    #endif
    return 0;
}