#include <bits/stdc++.h>
using namespace std;
// #include <ext/rope> //header with rope
// using namespace __gnu_cxx;
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
// using namespace __gnu_pbds;

#pragma GCC optimize("Ofast,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")

/// Typedef
typedef long double ld;
typedef long long ll;
typedef unsigned long ul;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pld;
typedef vector< pii > vii;

#define pb                  push_back
#define ppb                 pop_back
#define MP                  make_pair
#define ff                  first
#define ss                  second
#define sf                  scanf
#define pf                  printf
#define FOR(i, x, y)        for(int i=int(x); i<int(y); i++)
#define ROF(i, x, y)        for(int i=int(x)-1; i>=int(y); i--)
#define Binary(x,b)         std::bitset< b >( x ).to_string()
#define fastIO              ios::sync_with_stdio(false);    cin.tie(nullptr);   cout.tie(nullptr)
#define ran()               (((((1ULL*rand())<<31)|(1ULL*rand()))<<13)^((((1ULL*rand())<<32)|(1ULL*rand()))))
#define rran(a, b)          ((ran() % ((b) - (a) + 1)) + (a))
#define CLR(x, y)           memset(x, y, sizeof(x))
#define sc(n)               sf("%d",&n)
#define sc2(a,b)            sf("%d%d",&a,&b)
#define sc3(a,b,c)          sf("%d%d%d",&a,&b,&c)
#define sc4(a,b,c,d)        sf("%d%d%d%d",&a,&b,&c,&d)
#define scll(n)             sf("%lld",&n)
#define scll2(a,b)          sf("%lld%lld",&a,&b)
#define scll3(a,b,c)        sf("%lld%lld%lld",&a,&b,&c)
#define scll4(a,b,c,d)      sf("%lld%lld%lld%lld",&a,&b,&c,&d)
#define bitCheck(N,in)      ((bool)(N&(1LL<<(in))))
#define bitOff(N,in)        (N&(~(1LL<<(in))))
#define bitOn(N,in)         (N|(1LL<<(in)))
#define bitFlip(a,k)        (a^(1LL<<(k)))
#define bitCount(a)         __builtin_popcount(a)
#define bitCountLL(a)       __builtin_popcountll(a)
#define bitRightMost(a)     __builtin_ctzll(a)
#define bitLeftMost(a)      (63-__builtin_clzll(a))
#define SQR(x)              ((x)*(x))
#define mxEq(a,b)           (a = max(a,b))
#define all(c)              c.begin(), c.end()
#define unq(v)              sort(all(v)), (v).resize(unique(all(v)) - v.begin())
#define common(a,b)         sort(all(a)), sort(all(b)), a.erase(set_intersection(all(a),all(b),a.begin()),a.end())
#define uncommon(a,b)       sort(all(a)), sort(all(b)), a.erase(set_symmetric_difference(all(a),all(b),a.begin()),a.end())

// uniform random generator -->
// uniform_int_distribution<int> dist(0, 1);
// default_random_engine gen;

// *X.find_by_order(k) //returns the kth largest element.(0-based)
// X.order_of_key(val) //returns the no. of values less than val
// typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set; // C++98
// template <typename T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template <class T> inline T bigMod(T p,T e,T M){ T ret = 1; for(; e > 0; e >>= 1){ if(e & 1) ret = (ret * p) % M; p = (p * p) % M; } return (T) ret;}
template <class T> inline T modInverse(T a,T M){return bigMod(a,M-2,M);}
template <class T> inline T gcd(T a,T b){if(b==0)return a;return gcd(b,a%b);}
template <class T> inline T lcm(T a,T b) {a=abs(a);b=abs(b); return (a/gcd(a,b))*b;}
template <class T> inline string int2String(T a){ostringstream str; str<<a; return str.str();}
const int dr[] = { 0,  1,  0, -1,        -1,  1,  1, -1,     -2, -2,  2,  2, -1, -1,  1,  1};
const int dc[] = { 1,  0, -1,  0,         1,  1, -1, -1,     -1,  1, -1,  1, -2,  2, -2,  2};

/// Constants
#define MOD                 (int)(1e9+7)
#define eps                 1e-9
#define INF                 0x3f3f3f3f3f3f3f3f
#define inf                 0x3f3f3f3f // CLR(63)
#define PI                  (2.0*acos(0.0))  // 3.1415926535897932
#define Log(b,x)            (log(x)/log(b))

/// Debug
#define out(a,T,str)        copy(a.begin(),a.end()-1,ostream_iterator<T>(cout,str)),cout<<a.back()<<endl
#ifdef VAMP
    #define dbg(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template < typename Arg1 >
    void __f(const char* name, Arg1&& arg1){
        cout << name << " = " << arg1 << std::endl;
    }
    template < typename Arg1, typename... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args){
        const char* comma = strchr(names+1, ',');
        cout.write(names, comma - names) << " = " << arg1 <<" | ";
        __f(comma+1, args...);
    }
#else
    #define dbg(...)
#endif

/// Priority Queue custom compare
// bool cmp(const int &a, const int &b){ return a > b;}
// std::priority_queue<int, std::vector<int>, decltype(&cmp) > pq(cmp);

#include <tr1/unordered_map>
tr1 :: unordered_map<int,int> mp;
vector<int> X;

namespace SQRT_Decomposition {
    const int maxn = 1e5+500;

    struct BLOCK {
        vi v;
        vll sum;
    }
    b[int(sqrt(maxn))+1000];
    int N, block_size;

    inline void preprocess(){
        block_size = 1+int(sqrt(N))<<2;
        for(int i = 0; i*block_size < N; i++){
            b[i].v.clear();
            b[i].sum = vll(5,0);
        }
    }
    inline void add(const int &x){
        int P = mp[x];
        int r = P/block_size;
        b[r].v.pb(x);
        b[r].sum = vll(5,0);
        for(int i = b[r].v.size()-1; i > 0; i--){
            if(b[r].v[i-1] > b[r].v[i]) swap(b[r].v[i-1],b[r].v[i]);
            b[r].sum[i%5] += b[r].v[i];
        }
        b[r].sum[0] += b[r].v[0];
    }
    inline void del(const int &x){
        int P = mp[x];
        int r = P/block_size;
        b[r].sum = vll(5,0);
        for(int i = 0; i < b[r].v.size()-1; i++){
            if(b[r].v[i] == x) swap(b[r].v[i],b[r].v[i+1]);
            b[r].sum[i%5] += b[r].v[i];
        }
        b[r].v.ppb();
    }
    inline ll query(){
        ll sum = 0,sz = 0;
        for(int i = 0; i*block_size < N; i++){
            sum += b[i].sum[(2-sz+5)%5];
            sz = (sz+b[i].v.size())%5;
        }
        return sum;
    }
}
using namespace SQRT_Decomposition;

struct info{
    int type,x;
}Q[maxn];

char ch[10];
int main(){
    #ifdef VAMP
        int start_s=clock();
        freopen("input.txt","r",stdin);
        freopen("output.txt","w",stdout);
    #endif
    // fastIO;
    // srand((rand()-time(NULL))%MOD);

    int n; sc(n);
    FOR(i,0,n){
        sf("%s",ch);
        if(ch[0]=='s') Q[i].type = 0;
        else if(ch[0]=='a') Q[i].type = 1, sc(Q[i].x), X.pb(Q[i].x);
        else if(ch[0]=='d') Q[i].type = 2, sc(Q[i].x), X.pb(Q[i].x);
    }
    unq(X);
    N = X.size();
    FOR(i,0,N) mp[ X[i]] = i;

    preprocess();
    FOR(i,0,n){
             if(Q[i].type == 1) add(Q[i].x);
        else if(Q[i].type == 2) del(Q[i].x);
        else pf("%lld\n", query());
    }

    #ifdef VAMP
        int end_s=clock();
        printf("\nTime :: %.2lf\n", (double)(end_s-start_s)/CLOCKS_PER_SEC);
    #endif
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
// #include <ext/rope> //header with rope
// using namespace __gnu_cxx;
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
// using namespace __gnu_pbds;

#pragma GCC optimize("Ofast,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")

/// Typedef
typedef long double ld;
typedef long long ll;
typedef unsigned long ul;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pld;
typedef vector< pii > vii;

#define pb                  push_back
#define ppb                 pop_back
#define MP                  make_pair
#define ff                  first
#define ss                  second
#define sf                  scanf
#define pf                  printf
#define FOR(i, x, y)        for(int i=int(x); i<int(y); i++)
#define ROF(i, x, y)        for(int i=int(x)-1; i>=int(y); i--)
#define Binary(x,b)         std::bitset< b >( x ).to_string()
#define fastIO              ios::sync_with_stdio(false);    cin.tie(nullptr);   cout.tie(nullptr)
#define ran()               (((((1ULL*rand())<<31)|(1ULL*rand()))<<13)^((((1ULL*rand())<<32)|(1ULL*rand()))))
#define rran(a, b)          ((ran() % ((b) - (a) + 1)) + (a))
#define CLR(x, y)           memset(x, y, sizeof(x))
#define sc(n)               sf("%d",&n)
#define sc2(a,b)            sf("%d%d",&a,&b)
#define sc3(a,b,c)          sf("%d%d%d",&a,&b,&c)
#define sc4(a,b,c,d)        sf("%d%d%d%d",&a,&b,&c,&d)
#define scll(n)             sf("%lld",&n)
#define scll2(a,b)          sf("%lld%lld",&a,&b)
#define scll3(a,b,c)        sf("%lld%lld%lld",&a,&b,&c)
#define scll4(a,b,c,d)      sf("%lld%lld%lld%lld",&a,&b,&c,&d)
#define bitCheck(N,in)      ((bool)(N&(1LL<<(in))))
#define bitOff(N,in)        (N&(~(1LL<<(in))))
#define bitOn(N,in)         (N|(1LL<<(in)))
#define bitFlip(a,k)        (a^(1LL<<(k)))
#define bitCount(a)         __builtin_popcount(a)
#define bitCountLL(a)       __builtin_popcountll(a)
#define bitRightMost(a)     __builtin_ctzll(a)
#define bitLeftMost(a)      (63-__builtin_clzll(a))
#define SQR(x)              ((x)*(x))
#define mxEq(a,b)           (a = max(a,b))
#define all(c)              c.begin(), c.end()
#define unq(v)              sort(all(v)), (v).resize(unique(all(v)) - v.begin())
#define common(a,b)         sort(all(a)), sort(all(b)), a.erase(set_intersection(all(a),all(b),a.begin()),a.end())
#define uncommon(a,b)       sort(all(a)), sort(all(b)), a.erase(set_symmetric_difference(all(a),all(b),a.begin()),a.end())

// uniform random generator -->
// uniform_int_distribution<int> dist(0, 1);
// default_random_engine gen;

// *X.find_by_order(k) //returns the kth largest element.(0-based)
// X.order_of_key(val) //returns the no. of values less than val
// typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set; // C++98
// template <typename T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template <class T> inline T bigMod(T p,T e,T M){ T ret = 1; for(; e > 0; e >>= 1){ if(e & 1) ret = (ret * p) % M; p = (p * p) % M; } return (T) ret;}
template <class T> inline T modInverse(T a,T M){return bigMod(a,M-2,M);}
template <class T> inline T gcd(T a,T b){if(b==0)return a;return gcd(b,a%b);}
template <class T> inline T lcm(T a,T b) {a=abs(a);b=abs(b); return (a/gcd(a,b))*b;}
template <class T> inline string int2String(T a){ostringstream str; str<<a; return str.str();}
const int dr[] = { 0,  1,  0, -1,        -1,  1,  1, -1,     -2, -2,  2,  2, -1, -1,  1,  1};
const int dc[] = { 1,  0, -1,  0,         1,  1, -1, -1,     -1,  1, -1,  1, -2,  2, -2,  2};

/// Constants
#define MOD                 (int)(1e9+7)
#define eps                 1e-9
#define INF                 0x3f3f3f3f3f3f3f3f
#define inf                 0x3f3f3f3f // CLR(63)
#define PI                  (2.0*acos(0.0))  // 3.1415926535897932
#define Log(b,x)            (log(x)/log(b))

/// Debug
#define out(a,T,str)        copy(a.begin(),a.end()-1,ostream_iterator<T>(cout,str)),cout<<a.back()<<endl
#ifdef VAMP
    #define dbg(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template < typename Arg1 >
    void __f(const char* name, Arg1&& arg1){
        cout << name << " = " << arg1 << std::endl;
    }
    template < typename Arg1, typename... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args){
        const char* comma = strchr(names+1, ',');
        cout.write(names, comma - names) << " = " << arg1 <<" | ";
        __f(comma+1, args...);
    }
#else
    #define dbg(...)
#endif

/// Priority Queue custom compare
// bool cmp(const int &a, const int &b){ return a > b;}
// std::priority_queue<int, std::vector<int>, decltype(&cmp) > pq(cmp);

#include <tr1/unordered_map>
tr1 :: unordered_map<int,int> mp;
vector<int> X;

namespace SQRT_Decomposition {
    const int maxn = 1e5+500;

    struct BLOCK {
        vi v;
        vll sum;
    }
    b[int(sqrt(maxn))+1000];
    int N, block_size;

    inline void preprocess(){
        block_size = 1+int(sqrt(N*2));
        for(int i = 0; i*block_size < N; i++){
            b[i].v.clear();
            b[i].sum = vll(5,0);
        }
    }
    inline void add(const int &x){
        int P = mp[x];
        int r = P/block_size;
        b[r].v.pb(x);
        b[r].sum = vll(5,0);
        for(int i = b[r].v.size()-1; i > 0; i--){
            if(b[r].v[i-1] > b[r].v[i]) swap(b[r].v[i-1],b[r].v[i]);
            b[r].sum[i%5] += b[r].v[i];
        }
        b[r].sum[0] += b[r].v[0];
    }
    inline void del(const int &x){
        int P = mp[x];
        int r = P/block_size;
        b[r].sum = vll(5,0);
        for(int i = 0; i < b[r].v.size()-1; i++){
            if(b[r].v[i] == x) swap(b[r].v[i],b[r].v[i+1]);
            b[r].sum[i%5] += b[r].v[i];
        }
        b[r].v.ppb();
    }
    inline ll query(){
        ll sum = 0,sz = 0;
        for(int i = 0; i*block_size < N; i++){
            sum += b[i].sum[(2-sz+5)%5];
            sz = (sz+b[i].v.size())%5;
        }
        return sum;
    }
}
using namespace SQRT_Decomposition;

struct info{
    int type,x;
}Q[maxn];

char ch[10];
int main(){
    #ifdef VAMP
        int start_s=clock();
        freopen("input.txt","r",stdin);
        freopen("output.txt","w",stdout);
    #endif
    // fastIO;
    // srand((rand()-time(NULL))%MOD);

    int n; sc(n);
    FOR(i,0,n){
        sf("%s",ch);
        if(ch[0]=='s') Q[i].type = 0;
        else if(ch[0]=='a') Q[i].type = 1, sc(Q[i].x), X.pb(Q[i].x);
        else if(ch[0]=='d') Q[i].type = 2, sc(Q[i].x), X.pb(Q[i].x);
    }
    unq(X);
    N = X.size();
    FOR(i,0,N) mp[ X[i]] = i;

    preprocess();
    FOR(i,0,n){
             if(Q[i].type == 1) add(Q[i].x);
        else if(Q[i].type == 2) del(Q[i].x);
        else pf("%lld\n", query());
    }

    #ifdef VAMP
        int end_s=clock();
        printf("\nTime :: %.2lf\n", (double)(end_s-start_s)/CLOCKS_PER_SEC);
    #endif
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
// #include <ext/rope> //header with rope
// using namespace __gnu_cxx;
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
// using namespace __gnu_pbds;

#pragma GCC optimize("Ofast,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")

/// Typedef
typedef long double ld;
typedef long long ll;
typedef unsigned long ul;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pld;
typedef vector< pii > vii;

#define pb                  push_back
#define ppb                 pop_back
#define MP                  make_pair
#define ff                  first
#define ss                  second
#define sf                  scanf
#define pf                  printf
#define FOR(i, x, y)        for(int i=int(x); i<int(y); i++)
#define ROF(i, x, y)        for(int i=int(x)-1; i>=int(y); i--)
#define Binary(x,b)         std::bitset< b >( x ).to_string()
#define fastIO              ios::sync_with_stdio(false);    cin.tie(nullptr);   cout.tie(nullptr)
#define ran()               (((((1ULL*rand())<<31)|(1ULL*rand()))<<13)^((((1ULL*rand())<<32)|(1ULL*rand()))))
#define rran(a, b)          ((ran() % ((b) - (a) + 1)) + (a))
#define CLR(x, y)           memset(x, y, sizeof(x))
#define sc(n)               sf("%d",&n)
#define sc2(a,b)            sf("%d%d",&a,&b)
#define sc3(a,b,c)          sf("%d%d%d",&a,&b,&c)
#define sc4(a,b,c,d)        sf("%d%d%d%d",&a,&b,&c,&d)
#define scll(n)             sf("%lld",&n)
#define scll2(a,b)          sf("%lld%lld",&a,&b)
#define scll3(a,b,c)        sf("%lld%lld%lld",&a,&b,&c)
#define scll4(a,b,c,d)      sf("%lld%lld%lld%lld",&a,&b,&c,&d)
#define bitCheck(N,in)      ((bool)(N&(1LL<<(in))))
#define bitOff(N,in)        (N&(~(1LL<<(in))))
#define bitOn(N,in)         (N|(1LL<<(in)))
#define bitFlip(a,k)        (a^(1LL<<(k)))
#define bitCount(a)         __builtin_popcount(a)
#define bitCountLL(a)       __builtin_popcountll(a)
#define bitRightMost(a)     __builtin_ctzll(a)
#define bitLeftMost(a)      (63-__builtin_clzll(a))
#define SQR(x)              ((x)*(x))
#define mxEq(a,b)           (a = max(a,b))
#define all(c)              c.begin(), c.end()
#define unq(v)              sort(all(v)), (v).resize(unique(all(v)) - v.begin())
#define common(a,b)         sort(all(a)), sort(all(b)), a.erase(set_intersection(all(a),all(b),a.begin()),a.end())
#define uncommon(a,b)       sort(all(a)), sort(all(b)), a.erase(set_symmetric_difference(all(a),all(b),a.begin()),a.end())

// uniform random generator -->
// uniform_int_distribution<int> dist(0, 1);
// default_random_engine gen;

// *X.find_by_order(k) //returns the kth largest element.(0-based)
// X.order_of_key(val) //returns the no. of values less than val
// typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set; // C++98
// template <typename T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template <class T> inline T bigMod(T p,T e,T M){ T ret = 1; for(; e > 0; e >>= 1){ if(e & 1) ret = (ret * p) % M; p = (p * p) % M; } return (T) ret;}
template <class T> inline T modInverse(T a,T M){return bigMod(a,M-2,M);}
template <class T> inline T gcd(T a,T b){if(b==0)return a;return gcd(b,a%b);}
template <class T> inline T lcm(T a,T b) {a=abs(a);b=abs(b); return (a/gcd(a,b))*b;}
template <class T> inline string int2String(T a){ostringstream str; str<<a; return str.str();}
const int dr[] = { 0,  1,  0, -1,        -1,  1,  1, -1,     -2, -2,  2,  2, -1, -1,  1,  1};
const int dc[] = { 1,  0, -1,  0,         1,  1, -1, -1,     -1,  1, -1,  1, -2,  2, -2,  2};

/// Constants
#define MOD                 (int)(1e9+7)
#define eps                 1e-9
#define INF                 0x3f3f3f3f3f3f3f3f
#define inf                 0x3f3f3f3f // CLR(63)
#define PI                  (2.0*acos(0.0))  // 3.1415926535897932
#define Log(b,x)            (log(x)/log(b))

/// Debug
#define out(a,T,str)        copy(a.begin(),a.end()-1,ostream_iterator<T>(cout,str)),cout<<a.back()<<endl
#ifdef VAMP
    #define dbg(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template < typename Arg1 >
    void __f(const char* name, Arg1&& arg1){
        cout << name << " = " << arg1 << std::endl;
    }
    template < typename Arg1, typename... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args){
        const char* comma = strchr(names+1, ',');
        cout.write(names, comma - names) << " = " << arg1 <<" | ";
        __f(comma+1, args...);
    }
#else
    #define dbg(...)
#endif

/// Priority Queue custom compare
// bool cmp(const int &a, const int &b){ return a > b;}
// std::priority_queue<int, std::vector<int>, decltype(&cmp) > pq(cmp);

#include <tr1/unordered_map>
tr1 :: unordered_map<int,int> mp;
vector<int> X;

namespace SQRT_Decomposition {
    const int maxn = 1e5+500;

    struct BLOCK {
        vi v;
        vll sum;
    }
    b[int(sqrt(maxn))+1000];
    int N, block_size;

    inline void preprocess(){
        block_size = 1+int(sqrt(N<<1));
        for(int i = 0; i*block_size < N; i++){
            b[i].v.clear();
            b[i].sum = vll(5,0);
        }
    }
    inline void add(const int &x){
        int P = mp[x];
        int r = P/block_size;
        b[r].v.pb(x);
        b[r].sum = vll(5,0);
        for(int i = b[r].v.size()-1; i > 0; i--){
            if(b[r].v[i-1] > b[r].v[i]) swap(b[r].v[i-1],b[r].v[i]);
            b[r].sum[i%5] += b[r].v[i];
        }
        b[r].sum[0] += b[r].v[0];
    }
    inline void del(const int &x){
        int P = mp[x];
        int r = P/block_size;
        b[r].sum = vll(5,0);
        for(int i = 0; i < b[r].v.size()-1; i++){
            if(b[r].v[i] == x) swap(b[r].v[i],b[r].v[i+1]);
            b[r].sum[i%5] += b[r].v[i];
        }
        b[r].v.ppb();
    }
    inline ll query(){
        ll sum = 0,sz = 0;
        for(int i = 0; i*block_size < N; i++){
            sum += b[i].sum[(2-sz+5)%5];
            sz = (sz+b[i].v.size())%5;
        }
        return sum;
    }
}
using namespace SQRT_Decomposition;

struct info{
    int type,x;
}Q[maxn];

char ch[10];
int main(){
    #ifdef VAMP
        int start_s=clock();
        freopen("input.txt","r",stdin);
        freopen("output.txt","w",stdout);
    #endif
    // fastIO;
    // srand((rand()-time(NULL))%MOD);

    int n; sc(n);
    FOR(i,0,n){
        sf("%s",ch);
        if(ch[0]=='s') Q[i].type = 0;
        else if(ch[0]=='a') Q[i].type = 1, sc(Q[i].x), X.pb(Q[i].x);
        else if(ch[0]=='d') Q[i].type = 2, sc(Q[i].x), X.pb(Q[i].x);
    }
    unq(X);
    N = X.size();
    FOR(i,0,N) mp[ X[i]] = i;

    preprocess();
    FOR(i,0,n){
             if(Q[i].type == 1) add(Q[i].x);
        else if(Q[i].type == 2) del(Q[i].x);
        else pf("%lld\n", query());
    }

    #ifdef VAMP
        int end_s=clock();
        printf("\nTime :: %.2lf\n", (double)(end_s-start_s)/CLOCKS_PER_SEC);
    #endif
    return 0;
}


#include <bits/stdc++.h>

enum u {
    used,
    fr
};

enum chk {
    ok,
    sim,
    dif
};

chk xr(std::vector<char>& a, std::vector<char>& b) {
    for (size_t j = 0; j < a.size(); ++j) {
        if (a[j] != '.' || b[j] != '.') {
            if (a[j] == b[j]) {
                if (a == b) {
                    return ok;
                }
                return sim;

            }
        }
    }
    return dif;
}

int main() {
    uint64_t n, m;
    std::cin >> n >> m;
    std::vector<std::pair<u,std::vector<char>>> field(n, std::pair<u, std::vector<char>>(fr, std::vector<char>(m)));
    for (size_t i = 0; i < n; ++i) {
        for (size_t j = 0; j < m; ++j) {
            std::cin >> field[i].second[j];
        }
    }
    for (size_t i = 0; i < n; ++i) {
        if (field[i].first == fr) {
            field[i].first = used;
            for (size_t j = i + 1; j < n; ++j) {
                auto c = xr(field[i].second, field[j].second);
                if (c == ok) {
                    field[j].first = used;
                } else if (c == sim){
                    std::cout << "No" << std::endl;
                    return 0;
                }
            }
        }
    }
    std::cout << "Yes" << std::endl;
    return 0;
}


#include <bits/stdc++.h>

enum u {
    used,
    fr
};

enum chk {
    ok,
    sim,
    dif
};

chk xr(std::vector<char>& a, std::vector<char>& b) {
    bool pf = false;
    size_t a_count = 0, b_count = 0;
    for (size_t j = 0; j < a.size(); ++j) {
        if (a[j] != '.' || b[j] != '.') {
            if (a[j] != '.') ++a_count;
            if (b[j] != '.') ++b_count;
            if (a[j] == b[j]) {
                pf = true;
            } else if (pf) {
                return sim;
            }
        }
    }
    if (pf) {
        if (a_count == b_count)
            return ok;
        return sim;
    }
    return dif;
}

int main() {
    uint64_t n, m;
    std::cin >> n >> m;
    std::vector<std::pair<u,std::vector<char>>> field(n, std::pair<u, std::vector<char>>(fr, std::vector<char>(m)));
    for (size_t i = 0; i < n; ++i) {
        for (size_t j = 0; j < m; ++j) {
            std::cin >> field[i].second[j];
        }
    }
    for (size_t i = 0; i < n; ++i) {
        if (field[i].first == fr) {
            field[i].first = used;
            for (size_t j = i + 1; j < n; ++j) {
                auto c = xr(field[i].second, field[j].second);
                if (c == ok) {
                    field[j].first = used;
                } else if (c == sim){
                    std::cout << "No" << std::endl;
                    return 0;
                }
            }
        }
    }
    std::cout << "Yes" << std::endl;
    return 0;
}


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

#define int long long

#define x first
#define y second
#define pb push_back
#define mp make_pair

#define all(a) (a).begin(), (a).end()

int32_t main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, m;
    cin >> n >> m;
    vector<int> a;
    for (int i = 0; i < n; i++) {
        int x = 0;
        for (int j = 0; j < m; j++) {
            char c;
            cin >> c;
            if (c == '#') x |= 1LL << j;
        }
        a.pb(x);
    }
    for (auto x : a) {
        for (auto y : a) {
            int z = (x & y);
            if (z != 0 && x != y) {
                cout << "No\n";
                return 0;
            }
        }
    }
    cout << "Yes\n";
    return 0;
}


#include<bits/stdc++.h>
#define int long long int
using namespace std;
int32_t main()
{
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
int t=1;
    while(t--)
    {
    int n,m;
     cin>>n>>m;
     char arr[n][m];
     for(int i=0;i<n;i++)
     {
     for(int j=0;j<m;j++)
     cin>>arr[i][j];
     }
     for(int i=0;i<n-1;i++)
     {
     for(int j=i+1;j<n;j++)
     {
     bool all_same=true;
     bool no_intersect=true;
     for(int k=0;k<m;k++)
     {
     if(arr[i][k]!=arr[j][k])//checking if rows match completely,if they do not match at some point set all_same false.
         all_same=false;
     if(arr[i][k]=='#' && arr[j][k]=='#')//detecting common element if they are same then that point is point of common match . since if a row has common match at one point and mismatch at another then it is not possible to do hence answer
         no_intersect=false;
     }
         if(!all_same && !no_intersect)
         {
         cout<<"No"<<endl;
         exit(0);
         }
     }
     }
        cout<<"Yes"<<endl;
    }
return 0;
}


#include <iostream>
#include <vector>
#include <cmath>
#include <iomanip>
#include <algorithm>
#include <string>

#define pb push_back

using namespace std;

int main(){
    int x, y;
    cin >> x >> y;
    vector<vector<int>> mas(x,vector<int>(y));
    for(int i=0;i<x;i++){
        string st;
        cin >> st;
        for(int q=0;q<y;q++){
            if(st[q]=='#')
                mas[i][q]=1;
        }
    }
    vector<int> zan(x);
    for(int i=0;i<x;i++){
        if(zan[i]==0){
            vector<int> zanY(y);
            for(int q=0;q<y;q++){
                if(mas[i][q]==1){
                    zanY[q]=1;
                }
            }
            for(int q=i+1;q<x;q++){
                if(zan[q]==0){
                    int rav=0, tam=0;
                    for(int r=0;r<y;r++){
                        if(mas[q][r]==1){
                            if(zanY[r]==1){
                                rav=1;
                            }
                            else{
                                tam=1;
                            }
                        }
                        else{
                            if(zanY[r]==1)
                                tam=1;
                        }
                    }
                    if(rav==1){
                        if(tam==1){
                        cout << "No";
                        return 0;
                        }
                        else{
                            zan[q]=1;
                        }
                    }
                }
            }
        }
    }
    cout << "Yes";
}


#include <iostream>
#include <vector>
#include <cmath>
#include <iomanip>
#include <algorithm>
#include <string>

#define pb push_back

using namespace std;

int main(){
    int x, y;
    cin >> x >> y;
    vector<vector<int>> mas(x,vector<int>(y));
    for(int i=0;i<x;i++){
        string st;
        cin >> st;
        for(int q=0;q<y;q++){
            if(st[q]=='#')
                mas[i][q]=1;
        }
    }
    vector<int> zan(x);
    for(int i=0;i<x;i++){
        if(zan[i]==0){
            vector<int> zanY(y);
            for(int q=0;q<y;q++){
                if(mas[i][q]==1){
                    zanY[q]=1;
                }
            }
            for(int q=i+1;q<x;q++){
                if(zan[q]==0){
                    int rav=0, tam=0;
                    for(int r=0;r<y;r++){
                        if(mas[q][r]==1){
                            if(zanY[r]==1){
                                rav=1;
                            }
                            else{
                                tam=1;
                            }
                        }
                    }
                    if(rav==1){
                        if(tam==1){
                        cout << "No";
                        return 0;
                        }
                        else{
                            zan[q]=1;
                        }
                    }
                }
            }
        }
    }
    cout << "Yes";
}


#include <iostream>
#include <vector>
#include <cmath>
#include <iomanip>
#include <algorithm>
#include <string>

#define pb push_back

using namespace std;

int main(){
    int x, y;
    cin >> x >> y;
    vector<vector<int>> mas(x,vector<int>(y));
    for(int i=0;i<x;i++){
        string st;
        cin >> st;
        for(int q=0;q<y;q++){
            if(st[q]=='#')
                mas[i][q]=1;
        }
    }
    vector<int> zan(x);
    for(int i=0;i<x;i++){
        if(zan[i]==0){
            vector<int> zanY(y);
            for(int q=0;q<y;q++){
                if(mas[i][q]==1){
                    zanY[q]=1;
                }
            }
            for(int q=i+1;q<x;q++){
                if(zan[q]==0){
                    int rav=0, tam=0;
                    for(int r=0;r<y;r++){
                        if(mas[q][r]==1){
                            if(zanY[r]==1){
                                rav=1;
                            }
                            else{
                                tam=1;
                            }
                        }
                    }
                    if(rav==1&&tam==1){
                        cout << "No";
                        return 0;
                    }
                    zan[q]=1;
                }
            }
        }
    }
    cout << "Yes";
}


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

int n, m;
char s[55][55];

bool isE(int i, int j) {

    for(int k=1; k<=m; k++) {
        if(s[i][k] != s[j][k]) {
            return false;
        }
    }
    return true;
}

int main() {

    ios::sync_with_stdio(false);

    cin>>n>>m;

    for(int i=1; i<=n; i++) {
        for(int j=1; j<=m; j++) {
            cin>>s[i][j];
        }
    }

    bool selected[55] = {false};

    for(int i=1; i<=n; i++) {

        vector<int> in;

        if(!selected[i]) {

            for(int j=1; j<=n; j++) {
                if(isE(i, j)) {
                    in.push_back(j);
                }
            }

            for(int j=1; j<=m; j++) {

                if(s[i][j] == '#') {
                    for(int k=1; k<=n; k++) {
                        if(s[k][j] == '#') {
                            bool flag = true;
                            for(int l=0; l<in.size(); l++) {
                                if(in[l] == k) {
                                    flag = false;
                                    break;
                                }
                            }
                            if(flag) {
                                cout<<"NO\n";
                                return 0;
                            }
                        }
                    }
                }
            }

            for(int j=0; j<in.size(); j++) {
                selected[in[j]] = true;
            }
        }

    }

    cout<<"YES\n";
}


#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define int long long
#define ld long double
#define endl '\n'
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int, int>
#define vpii vector<pii>
#define gr vector<vpii>
#define str string
#define mask vector<bool>
#define vs vector<str>
#define si set<int>
#define pq priority_queue
#define ordered_set_of(T) tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>
#define fi first
#define se second
#define sz(x) (int)((x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define nub(x) x.resize(unique(all(x)) - x.begin())
#define TWO class T1, class T2
#define YES cout << "YES" << endl
#define NO cout << "NO" << endl
#define GAME_OVER return 0
using namespace std;
using namespace __gnu_pbds;
template<TWO> ostream& operator<<(ostream& o, pair<T1, T2> x) {return o << x.fi << ' ' << x.se;}
template<TWO> istream& operator>>(istream& i, pair<T1, T2>& x) {return i >> x.fi >> x.se;}
template<class T> ostream& operator<<(ostream& o, vector<T> x) {for (auto it : x) o << it << ' '; return o;}
template<TWO> ostream& operator<<(ostream& o, vector<pair<T1, T2>> x) {for (int i = 0; i < sz(x); i++) o << x[i] << (i < sz(x) - 1 ? endl : ' '); return o;}
template<class T> ostream& operator<<(ostream& o, vector<vector<T>> x) {for (int i = 0; i < sz(x); i++) o << x[i] << (i < sz(x) - 1 ? endl : ' '); return o;}
template<class T> istream& operator>>(istream& i, vector<T>& x) {for (auto& it : x) i >> it; return i;}
signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0), cout.tie(0);
    int n, m;
    cin >> n >> m;
    vs a(n);
    cin >> a;
    for (int i = 0; i < n; i++)
        for (int j = i + 1; j < n; j++)
        {
            bool b = true, c = true;
            for (int k = 0; k < m; k++)
            {
                b &= a[i][k] == a[j][k];
                c &= a[i][k] == '.' || a[j][k] == '.';
            }
            if (!b && !c)
            {
                NO;
                GAME_OVER;
            }
        }
    YES;
    GAME_OVER;
}


#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define int long long
#define ld long double
#define endl '\n'
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int, int>
#define vpii vector<pii>
#define gr vector<vpii>
#define str string
#define mask vector<bool>
#define vs vector<str>
#define si set<int>
#define pq priority_queue
#define ordered_set_of(T) tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>
#define fi first
#define se second
#define sz(x) (int)((x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define nub(x) x.resize(unique(all(x)) - x.begin())
#define TWO class T1, class T2
#define YES cout << "YES" << endl
#define NO cout << "NO" << endl
#define GAME_OVER return 0
using namespace std;
using namespace __gnu_pbds;
template<TWO> ostream& operator<<(ostream& o, pair<T1, T2> x) {return o << x.fi << ' ' << x.se;}
template<TWO> istream& operator>>(istream& i, pair<T1, T2>& x) {return i >> x.fi >> x.se;}
template<class T> ostream& operator<<(ostream& o, vector<T> x) {for (auto it : x) o << it << ' '; return o;}
template<TWO> ostream& operator<<(ostream& o, vector<pair<T1, T2>> x) {for (int i = 0; i < sz(x); i++) o << x[i] << (i < sz(x) - 1 ? endl : ' '); return o;}
template<class T> ostream& operator<<(ostream& o, vector<vector<T>> x) {for (int i = 0; i < sz(x); i++) o << x[i] << (i < sz(x) - 1 ? endl : ' '); return o;}
template<class T> istream& operator>>(istream& i, vector<T>& x) {for (auto& it : x) i >> it; return i;}
signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0), cout.tie(0);
    int n, m;
    cin >> n >> m;
    vs a(n);
    cin >> a;
    for (int i = 0; i < n; i++)
        for (int j = i + 1; j < n; j++)
        {
            bool b = true, c = true;
            for (int k = 0; k < m; k++)
            {
                b &= a[i][k] == a[j][k];
                c &= a[i][k] == '.' || a[j][k] == '.';
            }
            if (!a && !b)
            {
                NO;
                GAME_OVER;
            }
        }
    YES;
    GAME_OVER;
}


#include<bits/stdc++.h>
using namespace std;
#define FS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long int
#define MAX_INT 100000
#define ld long double
#define pb push_back
#define pu push
#define bp __builtin_popcount
#define vsz(v) cout<<v.size()<<endl;
#define printv(v) for(ll i=0;i<v.size();i++)cout<<v[i]<<" "; cout<<endl;
#define printa(a,n) for(ll i=0;i<n;i++)cout<<a[i]<<" ";cout<<endl;
#define printrv(v) for(ll i=v.size()-1;i>=0;i--)cout<<v[i]<<" "; cout<<endl;
#define printvpair(v) for(ll i=0;i<v.size();i++)cout<<v[i].first<<" "<<v[i].second<<endl;
#define sz size()
#define ff first
#define ss second
#define vll vector<ll>
#define vbool vector<bool>
#define vpll vector<pair<ll,ll>>
#define vvpll vector<vector<pair<ll,ll>>>
#define qll queue<ll>
#define dqll deque<ll>
#define pll pair<ll,ll>
#define vllv vector<vector<ll>>
#define vstr vector<string>
#define setpri(x) cout<<setprecision(x);
#define all(v) v.begin(),v.end()
#define allr(v) v.rbegin(),v.rend()
#define scana(a,n) for(ll i=0;i<n;i++)cin>>a[i];
#define inf 1000000000000
#define yes cout<<"YES"<<endl
#define no cout<<"NO"<<endl
#define yesr {cout<<"YES"<<endl;return;}
#define nor {cout<<"NO"<<endl;return;}
ll MOD=1e9+7;
ll ceil1(ll n,ll x){if(n%x==0)return n/x; else return (n/x)+1;}
ll gcd(ll a,ll b){return __gcd(a,b);}
ll lcm(ll a,ll b){return (max(a,b)/gcd(a,b))*min(a,b);}
ll pow1(ll n,ll k,ll mm){
    if(k==0)return 1;
    if(k%2==0)return (pow1((n%mm)*(n%mm),k/2,mm))%mm;
    return ((n%mm)*(pow1((n%mm)*(n%mm),k/2,mm)%mm))%mm;
}
ll pow2(ll n,ll k){ll ans=1;
	while(k>0){
        if(k%2==1)ans=ans*n;n=n*n;k/=2;
    }return ans;
}
ll modinv(ll A,ll M){return pow1(A,M-2,M);}
ll fact(ll n){ll s=1; for(ll i=1;i<=n;i++)s*=i; return s;}
ll factmod(ll n,ll mod){ll s=1; for(ll i=1;i<=n;i++){s*=i;s%=mod;} return s;}
vll fact1tonmod(ll n,ll mod){vll  ans(n+1);ans[0]=ans[1]=1;
	for(ll i=2;i<=n;i++)ans[i]=(ans[i-1]*i)%mod;
	return ans;
}
ll ncrmod(ll n,ll r,ll mod){
	ll ans=((((factmod(n,mod)%mod)*(modinv(factmod(r,mod),mod)%mod))%mod)*(modinv(factmod(n-r,mod),mod)))%mod;
	return ans;
}
ll ncr(ll n,ll r){if(n==1 || r==0)return 1;if(r>n/2)r=n-r;
	ll ans=1;for(ll i=1;i<=r;i++){ans=((ans * n )/i);n--;}return ans;
}
ll ncrsum(ll n,ll r, ll mod){
	if(n==1 || r==0)return 1;
	ll ans=1,sum=1;for(ll i=1;i<=r;i++){ans=(((ans * n )/i)%mod);n--;sum+=ans;sum%=mod;}return sum;
}
bool isprime(ll n){if(n==1 || (n!=2 && n%2==0))return false; if(n==2)return true;
		for(ll i=3;i<=sqrt(n);i+=2)if(n%i==0)return false; return true; }
vll createprime(ll n){
	vector<bool> prime(n+1,true);vll ans;;prime[0]=prime[1]=false;
	for(ll i=2;i*i<=n;i++)if(prime[i])for(ll j=i*i;j<=n;j+=i)prime[j]=false;
	for(ll i=2;i<=n;i++)if(prime[i])ans.pb(i);
	return ans;
}
vbool createprimebool(ll n){
	vector<bool> prime(n+1,true);prime[0]=prime[1]=false;
	for(ll i=2;i*i<=n;i++)if(prime[i])for(ll j=i*i;j<=n;j+=i)prime[j]=false;
	return prime;
}
vll factor(ll n){
	vll ans;
	if(n>0)ans.pb(1);if(n==2)ans.pb(2);
	for(ll i=2;i*i<=n;i++){if(n%i==0){ans.pb(i);if(n/i!=i)ans.pb(n/i);}}if(n>2)ans.pb(n);
	return ans;
}
ll numoffactor(ll n){ return factor(n).sz;}
bool func(pair<ll,ll> &a,pair<ll,ll> &b ){
	if(a.ff != b.ff)return a.ff < b.ff;
	return a.ss > b.ss;
}
bool chk(ll i,ll j,ll k){
	ll a[3]={i,j,k};
	sort(a,a+3);
	return a[0]+a[1]>a[2];
}
void solve(){
	ll i,j,k,n,m,x,y,z,d,l,r;
	cin>>n>>m;
	vstr s(n);
	ll sum=0;
	for(i=0;i<n;i++){
		cin>>s[i];
		for(j=0;j<m;j++){
			if(s[i][j])sum++;
		}
	}
	// cout<<sum<<endl;
	for(i=0;i<n;i++){
		vll v;
		for(j=0;j<m;j++){
			if(s[i][j]=='#')v.pb(j);
		}
		vll v1;
		if(v.sz>0){
		for(j=0;j<n;j++){
			if(s[j][v[0]]=='#')v1.pb(j);
		}
		}
		for(j=0;j<v1.sz;j++){
			if(s[v1[j]]!=s[v1[0]]){
				cout<<"NO";
				return;
			}
		}
		for(j=0;j<v.sz;j++){
			for(k=0;k<n;k++){
				if(s[k][v[0]]!=s[k][v[j]]){
					cout<<"No";
					return;
				}
			}
		}
		// printv(v);
		// printv(v1);
	}
	cout<<"YEs";

}
int main(){
	FS;
	ll i,j,k,n,m,x,y,z,q;
	q=1;
	// cin>>q;
	while(q--){
		solve();
	}
	return 0;
}


//Mark XIX
#include<bits/stdc++.h>

#define big(x) greater<x>()
#define ll long long int
#define M 1000000007
#define mp make_pair
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define deb(x) cerr<<#x<<" "<<x<<"\n";
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0);

int temp;
using namespace std;

void solve()
{
  int n,m;
  cin>>n>>m;
  int a[n][m];
  string s[n];
  for (int i = 0; i < n; ++i)
  {
   cin>>s[i];
   int j=0;
   for(auto ii:s[i])
    if(ii=='#') a[i][j++]=1;
    else a[i][j++]=0;
  }
  for (int j = 0; j < m; ++j)
  {
    std::vector<int> v;
    for (int i = 0; i < n; ++i)
      if(a[i][j]==1) v.pb(i);

    for (int i = 1; i < v.size(); ++i)
      if(s[v[0]]!=s[v[i]]) { cout<<"NO"; return; }
  }
  cout<<"YES";

}

int main()
{
  //Skipped in presense of online judge.
  #ifndef ONLINE_JUDGE
  freopen("/home/zeddie/Documents/input.txt","r",stdin);
  freopen("/home/zeddie/Documents/output.txt","w",stdout);
  freopen("/home/zeddie/Documents/error.txt","w",stderr);
  #endif

  IOS()
  ll t=1;
  //cin>>t;
  while(t--)
  {
    solve();
    cout<<"\n";
    deb('\n')
  }
}


#include <iostream>
#include <vector>

int main(){
    long n, m; std::cin >> n >> m;
    bool possible(true);
    std::vector<long> color(m, 0);

    for(long row = 1; row <= n; row++){
        std::string s; std::cin >> s;
        long cur(-1);
        for(int col = 0; col < m; col++){
            if(s[col] == '#'){
                if(!color[col]){color[col] = row;}
                if(cur == -1){cur = color[col];}
                if(cur != color[col]){possible = false;}
            }
            else if(color[col] == cur){possible = false;}
        }
    }

    puts(possible ? "Yes" : "No");

    return 0;
}


#include <iostream>
#include <vector>

int main(){

    long n,m; std::cin >> n >> m;
    std::vector<long> color(m + 1, 0);

    bool possible(true);
    for(long p = 1; p <= n; p++){
        std::string s; std::cin >> s;
        long cur = -1;
        for(long q = 1; q <= m; q++){
            if(s[q] == '#'){
                if(!color[q]){color[q] = p;}
                if(cur == -1){cur = color[q];}
                if(cur != color[q]){possible = false;}
            }
            else if(color[q] == cur){possible = false;}
        }
    }

    puts(possible ? "Yes" : "No");

    return 0;
}


//-----Sakib-----//
#include<bits/stdc++.h>
#include<iostream>
#include<vector>
#include<string>
#include<cstring>
#include<cstdio>
#include<map>
#include<set>
#include<utility>
#include<algorithm>
#include<cstdlib>
using namespace std;

// - - - - - - Data Types - - - - - - //

#define SF1(A)              scanf("%d", &A)
#define SF2(A,B)            scanf("%d %d", &A, &B)
#define SF3(A,B,C)          scanf("%d %d %d", &A, &B, &C)

typedef long long int LLI;
typedef unsigned long long int ULL;
#define SL1(A)              scanf("%lld", &A)
#define SL2(A,B)            SL1(A);SL1(B)
#define SL3(A,B,C)          SL2(A,B);SL1(C)

#define SD1(A)              scanf("%lf", &A)
#define SD2(A,B)            SD1(A);SD1(B)
#define SD3(A,B,C)          SD2(A,B);SD1(C)

// - - - - - - Vectors - - - - - - //
typedef vector<int> VI;
typedef vector<LLI> VLLI;
typedef vector<string> VS;
typedef vector<double> VD;
typedef vector<VI> VVI;

#define scanVI(V, N)        for(int I=0; I<N; I++){ int X; SF1(X); V.PB(X); }
#define scanVLLI(V, N)      for(int I=0; I<N; I++){ LLI X; SL1(X); V.PB(X); }
#define scanVS(V, N)        for(int I=0; I<N; I++){ string X; cin >> X; V.PB(X); }
#define scanVD(V, N)        for(int I=0; I<N; I++){ double X; SD1(X); V.PB(X); }

// - - - - - - Maps - - - - - - //
typedef map<int, int> MII;
typedef map<int, string> MIS;
typedef map<int, char> MIC;
typedef map<string, int> MSI;
typedef map<char, int> MCI;
typedef map<int, VI> MIVI;

// - - - - - - Pairs - - - - - - //
typedef pair<int, int> PII;
typedef pair<string, string> PSS;
typedef pair<char, char> PCC;
typedef pair<int, string> PIS;
typedef pair<int, char> PIC;
typedef pair<string, char> PSC;

// - - - - - - Sets - - - - - - //
typedef set<int> SI;
typedef set<LLI> SLLI;
typedef set<string> SS;
typedef set<char> SC;
// - - - - - - - - - - - - - - - - - - //

//#pragma GCC optimize("Ofast,no-stack-protector")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma GCC optimize("unroll-loops")

#define PF                  printf
#define SF                  scanf
#define PB                  push_back
#define SR(N)               right<<setw(N)
#define SL(N)               left<<setw(N)
#define PREC(N)             fixed << setprecision(N)
#define POP                 pop_back()
#define PP                  prev_permutation
#define NP                  next_permutation
#define MP                  make_pair
#define CLRN(a, b)          memset(a, b, sizeof(a))
#define CLR(a)              memset(a, 0, sizeof(a))
#define ALL(a)              a.begin(), a.end()
#define ALLN(a, n)          (a, a+n)
#define BSRCN(a, n, x)      binary_search(ALLN(a, n), x)
#define BSRC(a, z)          binary_search(ALL(a), z)
#define MAX                 10000007
#define MIN                 -10000007
#define PI                  acos(-1)
#define BR                  puts("")
#define FastIO              { ios_base::sync_with_stdio(false); cin.tie(nullptr); cin.tie(nullptr); }
#define READ()              freopen("input.txt", "r", stdin)
#define WRITE()             freopen("output.txt", "w", stdout)
#define IO                  READ(); WRITE();
#define SEED                srand((rand()-time(NULL)))
#define ran()               (((((1ULL*rand())<<31)|(1ULL*rand()))<<13)^((((1ULL*rand())<<32)|(1ULL*rand()))))
#define rran(a, b)          ((ran() % ((b) - (a) + 1)) + (a))
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - //
/*----------------------Graph Moves----------------*/
int ROW[]={+1,-1,+0,+0};
int COL[]={+0,+0,+1,-1};

int X[]={+0,+0,+1,-1,-1,+1,-1,+1};   // Kings Move
int Y[]={-1,+1,+0,+0,+1,+1,-1,-1};  // Kings Move

int KX[]={-2, -2, -1, -1,  1,  1,  2,  2};  // Knights Move
int KY[]={-1,  1, -2,  2, -2,  2, -1,  1}; // Knights Move

int basePrime[]={1009, 1013, 1019, 1021, 1031, 1223, 1229, 1231, 1237, 1249, 1289, 1291, 1297, 1301, 1303, 353, 359, 367, 373, 379, 859, 863, 877, 881, 883,
                1931, 1933, 1949, 1951, 1973, 401, 409, 419, 421, 431, 1709,  1721, 1723, 1733, 1741, 3499, 3511, 3517, 3527, 3529, 929, 937, 941, 947, 953};
/*----------------------------------------------------------------------------------------------------------------------------------------------*/

template<class XXX> XXX GCD(XXX a, XXX b) { return b == 0 ? a : GCD(b , a % b); }
template<class XXX> XXX LCM(XXX a, XXX b) { return a * (b/GCD(a, b)); }
template<class XXX, class YYY> bool CMP(XXX a, YYY b) { return a>b; }
template<class XXX> void fastread(XXX &number){ bool negative = false; register XXX c; number = 0; c=getchar();
if (c=='-')	{ negative = true; c=getchar(); }
	for (; (c>47 && c<58); c=getchar())	number = number *10 + c - 48;
	if (negative)number *= -1;
}

//clock_t Start=clock(); void Time(){ printf("\n>>Runtime: %.10fs\n", (double) (clock() - Start) / CLOCKS_PER_SEC); }

// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - END - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - //

int main()
{
    int n, m; cin >> n >> m;
    string s[n+5], s1[n+5];
    for(int i=0; i<n; i++) cin >> s[i];
    for(int i=0; i<n; i++)
    {
        s1[i]="";
        for(int j=0; j<m; j++) s1[i]+='.';
    }

    VI row(n+5, 0), col(m+5, 0);

    for(int i=0; i<n; i++)
    {
        VI r, c;
        r.PB(i); row[i]=1;
        for(int j=0; j<r.size(); j++)
        {
            for(int k=0; k<m; k++)
            { //if(r[j]==0) cout << (s[r[j]][k]=='#') << endl;
                if(col[k]) continue;
                if(s[r[j]][k]=='#')
                {
                    c.PB(k); col[k]=1;
                    for(int l=r[j]+1; l<n; l++)
                    {
                        if(s[l][k]=='#' and !row[l])
                        {
                            row[l]=1;
                            r.PB(l);
                        }
                    }
                }
            }
        }//for(int i:c) cout << i << ' '; BR;

        for(int j:r)
        {
            for(int k:c)
            {//cout << j << ' ' << k << endl;
                s1[j][k]='#';
            }
        }
    }

    for(int i=0; i<n; i++)
    {
        for(int j=0; j<m; j++)
        {
            if(s[i][j]!=s1[i][j])
            {
                puts("NO");
                return 0;
            }
        }
    }

    puts("YES");

    return 0;
}


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

#define double long double
#define vec vector
#define pb push_back
#define unset unordered_set
#define ii pair<int, int>
#define X first
#define Y second
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define FORE(i, a, b) for(int i = (a); i <= (b); i++)
#define FORD(i, a, b) for(int i = (a); i >= (b); i--)
#define bitcount(n) __builtin_popcountll(n)
template <typename T,typename U>
std::pair<T,U> operator+(const std::pair<T,U> & l,const std::pair<T,U> & r) {
  return {l.first+r.first,l.second+r.second};
}
typedef void (*callback_function)(void); // type for conciseness
const long long ZERO = 0LL;
const long long INF64 = 1e18;
const int INF32 = 1e9;
const int MOD = 1e9 + 7;
const double PI = acos(-1.0L);
const double EPS = static_cast<double>(1e-9);
typedef long long ll;

// If I need to find (x / a) % b, I need to use this function:
//    (x / a) % b = (x * inv(a, b)) % b
ll inv(ll a, ll b) {
  if (a != 1) {
    return b - (inv(b % a, a) * b) / a;
  }
  return 1;
}

inline int Pow(int a, int k) {
  int s = 1;
  for(; k; k >>= 1) {
    k & 1 ? s = 1LL * s * a % MOD : 0;
    a = 1LL * a * a % MOD;
  }
  return s;
}

// Init variables here
const int N = 1e6 + 7;

void input() {
  //freopen("??.in", "r", stdin);
  //freopen("??.out", "w", stdout);
}

void output() {

}

void preprocess() {

}

void debug() {
  if (true) {

  }
}

void solve() {
  preprocess();
  int n, m;
  cin >> n >> m;
  string s[n];
  FOR(i, 0, n) {
    cin >> s[i];
  }
  FOR(i, 1, n) FOR(j, 0, i) {
    if (s[i] != s[j]) {
      FOR(k, 0, m) {
        if (s[i][k] == s[j][k] and s[i][k] == '#') {
          cout << "No" << endl; return;
        }
      }
    }
  }
  cout << "Yes" << endl;
  //debug();
  // read the question correctly (is y a vowel?)
  // look out for SPECIAL CASES (n=1?) and overflow (ll vs int?)
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie();
  //auto beginProgram = chrono::steady_clock::now();

  //int t; cin >> t;
  //while (t--)
  {
    input();
    solve();
    output();
  }

  //auto endProgram = chrono::steady_clock::now();

  return 0;
}


#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <unordered_map>
#include <random>
#include <set>
#include <queue>

using namespace std;

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

#define fo(i, n) for (int i = 0; i < n; ++i)
#define foback(i, n) for (int i = n - 1; i >= 0; --i)
#define fo1(i, n) for (int i = 1; i <= n; ++i)

typedef long long ll;

void fastio()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
}

void one();

int main()
{
    fastio();

    int t = 1;
    // cin >> t;
    fo(i, t)
    {
        one();
    }
    return 0;
}

void one()
{
    int n;
    cin >> n;
    int m;
    cin >> m;
    map<ll, int> ma;
    fo(i, n)
    {
        string s;
        cin >> s;

        ll val = 0;
        fo(j, m)
        {
            char c = s[j];
            ll b = c == '#' ? 1 : 0;

            val += b << j;
        }

        ma[val]++;
    }

    vector<ll> v;
    for (auto [x, cnt] : ma)
    {
        v.push_back(x);
    }

    int ok = 1;
    ll ans = 0;
    for (auto x : v)
    {
        if (ans & x)
        {
            ok = 0;
            break;
        }
        ans |= x;
    }
    // while (1)
    // {
    //     auto x = v.back();
    //     v.pop_back();
    //     if (v.empty())
    //         break;

    //     foback(i, v.size())
    //     {
    //         if (v[i] & x > 0)
    //         {
    //             ok = 0;
    //             break;
    //         }
    //     }
    // }

    cout << (ok ? "Yes" : "No") << "\n";
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,m;
    cin>>n>>m;
    char a[n][m];
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<m;j++)
        {
            cin>>a[i][j];
        }
    }
    map<int,int> mp1;
    map<string,int> mp2;
    string s="";
    int cc=0;
    for(int i=0;i<n;i++)
    {
        s="";
        vector<int> v;
        for(int j=0;j<m;j++)
        {
            if(a[i][j]=='#')
            {
                s=s+to_string(j);
                v.push_back(j);
            }
        }
        if(mp2.find(s)==mp2.end())
        {
            for(int j=0;j<v.size();j++)
            {
                if(mp1.find(v[j])!=mp1.end())
                {
                    cc=1;
                    break;
                }
                else
                mp1[v[j]]=1;
            }
            mp2[s]=1;
        }
    }
    if(cc==1)
     cout<<"NO"<<endl;
    else
     cout<<"YES"<<endl;
}


#include <bits/stdc++.h>

//#define FAST_ALLOCATOR_MEMORY 210000000
#define y1 yy11
#define sqr(x) ((x)*(x))

//#include "optimization.h"

using namespace std;

typedef int ll;
typedef long long llu;
const ll maxn = 55;

char mas[maxn][maxn];
bool used1[maxn];
bool used2[maxn];

inline int solve() {
    ll n, m;
    cin >> n >> m;
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < m; ++j) {
            cin >> mas[i][j];
        }
    }
    for (int i = 0; i < n; ++i) {
        vector<ll> ids;
        for (int j = 0; j < m; ++j) {
            if (mas[i][j] == '#') ids.push_back(j);
        }
        if (ids.empty()) continue;
        if (used1[i]) {
            cout << "No";
            return 0;
        }
        for (int k = i + 1; k < n; ++k) {
            bool isneed = false;
            for (auto l : ids) {
                if (mas[k][l] == '#') isneed = true;
            }
            if (isneed) {
                used1[k] = true;
                for (auto l : ids) {
                    if (mas[k][l] == '.') {
                        cout << "No";
                        return 0;
                    } else {
                        mas[k][l] = '.';
                    }
                }
            }
        }
    }
    cout << "Yes";
}

int main() {
#ifdef DEBUG
    freopen("input.txt", "r", stdin);
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    solve();
    return 0;
}


#include <bits/stdc++.h>

//#define FAST_ALLOCATOR_MEMORY 210000000
#define y1 yy11
#define sqr(x) ((x)*(x))

//#include "optimization.h"

using namespace std;

typedef int ll;
typedef long long llu;
const ll maxn = 55;

char mas[maxn][maxn];
bool used1[maxn];
bool used2[maxn];

inline int solve() {
    ll n, m;
    cin >> n >> m;
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < m; ++j) {
            cin >> mas[i][j];
        }
    }
    for (int i = 0; i < n; ++i) {
        vector<ll> ids;
        for (int j = 0; j < m; ++j) {
            if (mas[i][j] == '#') ids.push_back(j);
        }
        if (ids.empty()) continue;
        if (used1[i]) {
            cout << "No";
            return 0;
        }
        for (int k = i + 1; k < n; ++k) {
            bool isneed = false;
            for (auto l : ids) {
                if (mas[k][l] == '#') isneed = true;
            }
            if (isneed) {
                if (used1[k]) {
                    cout << "No";
                    return 0;
                }
                used1[k] = true;
                for (auto l : ids) {
                    if (mas[k][l] == '.') {
                        cout << "No";
                        return 0;
                    } else {
                        mas[k][l] = '.';
                    }
                }
            }
        }
    }
    cout << "Yes";
}

int main() {
#ifdef DEBUG
    freopen("input.txt", "r", stdin);
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    solve();
    return 0;
}


#include <bits/stdc++.h>
        #include<string>
        using namespace std;
        #define pb push_back
        #define endl '\n'
        #define all(x) (x).begin(), (x).end()
        #define forn(i, n) for (int i = 0; i < (int)(n); i++)
        #define init(arr,value) memset(arr,value,sizeof(arr))
        #define test unsigned int tet;cin >> tet;while(tet--)
        #define sz(a) int((a).size())
        typedef long long ll;
        typedef unsigned long long ull;
        typedef long double ld;
        typedef vector<int> vi;
        typedef pair<int, int> pii;
        typedef pair<ll, ll> pll;
        #define sf scanf
        #define pf printf
        #define SUM(v) accumulate(all(v),ll(0))
        #define present(container, element) (container.find(element) != container.end())
        #define cpresent(container, element) (find(all(container),element) != container.end())
        int max(int a,float b){
            if(a>b)
               return a;
            return b;
        }
        ll gcd(ll a,ll b){
            if(a%b==0)
                return b;
            else
                return gcd(b,a%b);
        }
        ll lcm(ll a,ll b){
            return a*b/gcd(max(a,b),min(a,b));
        }
        bool sort_pair(pair<int,int>a,pair<int,int> b){
           return a.first<b.first;
        }
        bool sort_pair_(pair<int,int>a,pair<int,int>b){
            return a.second>b.second;
        }
        bool isprime(int x){
            for(int i=2;i<=sqrt(x);i++){
                if(x%i==0)
                return 0;
            }
            return 1;
        }
        int a[100001];
        int find(int p){
                if(a[p]<0){
                    return p;
                }
                return a[p]=find(a[p]);
            }
            void _union(int p,int q){
                 if(p>q){
                 a[p]+=a[q];
                 a[q]=p;
                 }
                 else{
                     a[q]+=a[p];
                     a[p]=q;
                 }

            }
        int main() {
            int n,m;
            sf("%d %d",&n,&m);
            string s[n];
            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]=='#'){
                        for(int k=i;k<n;k++){
                            if(s[i][j]==s[k][j]&&s[i]!=s[k]){
                                cout<<"NO";
                                return 0;
                            }
                        }
                    }
                }

            }
            cout<<"YES";

        }


#include<bits/stdc++.h>

using namespace std;

signed main() {
//	ios::sync_with_stdio(false);
//	cin.tie(0);
	int n, m;
	cin >> n >> m;
	vector <vector <char> > a(n, vector <char> (m));
	for(int i = 0; i < n; i++)
	{
		for(int j = 0; j < m; j++)
		{
			cin >> a[i][j];
		}
	}
	vector <bool> used(n), used1(m);
	for(int i = 0; i < n; i++)
	{
		for(int j = 0; j < m; j++)
		{
			if(a[i][j] == '#' && !used[i] && !used1[j])
			{
				int cnt1 = 0, cnt2 = 0;
				int c = 0;
				queue <int> q1, q2;
				q1.push(i);
				q2.push(j);
				used[i] = used1[j] = 1;
				while(q1.size() + q2.size() != 0)
				{
					while(q1.size() != 0)
					{
						cnt1++;
						int v = q1.front();
						q1.pop();
						for(int k = 0; k < m; k++)
						{
							if(a[v][k] == '#')
							{
								c++;
							}
							if(a[v][k] == '#' && !used1[k])
							{
								used1[k] = 1;
								q2.push(k);
							}
						}
					}
					while(q2.size() != 0)
					{
						cnt2++;
						int v = q2.front();
						q2.pop();
						for(int k = 0; k < n; k++)
						{
							if(a[k][v] == '#' && !used[k])
							{
								used[k] = 1;
								q1.push(k);
							}
						}
					}
				}
	//			cout << c << " " << cnt1 << " " << cnt2 << "\n";
				if(c < cnt1 * cnt2)
				{
					cout << "No\n";
					return 0;
				}
			}
		}
	}
	cout << "Yes";
	return 0;
}


// Author : deetav
// Happy stalking ! :P
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
using namespace std;
#define test  \
    int t;    \
    cin >> t; \
    while (t--)
#define ll long long
#define ld long double
#define endl "\n"

const ld PI = acos(-1);
const int N = 1e5 + 10;
const int MOD = 1e9 + 7;
const int mod1 = 998244353;
const ll INF = 2e18;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);cout.tie(nullptr);cerr.tie(nullptr);
    //test
    {
        vector <int> v[55];
        int n,m;cin>>n>>m;
        for(int i=0;i<n;i++){
            string s;cin>>s;
            for(int j=0;j<m;j++){
                if(s[j]=='#'){
                    v[i].emplace_back(j);
                }
            }
        }
        for(int i=0;i<n;i++){
           sort(v[i].begin(),v[i].end());
        }
        for(int i=0;i<n;i++){
            for(int j=0;j<n;j++){
                if(v[i]!=v[j]){
                    for(int x=0;x<v[i].size();x++){
                        for(int y=0;y<v[j].size();y++){
                            if(v[i][x]==v[j][y]){
                                return cout<<"No",0;
                            }
                        }
                    }
                }
            }
        }
        cout<<"Yes";
    }
    return 0;
}


// Author : deetav
// Happy stalking ! :P
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
using namespace std;
#define test  \
    int t;    \
    cin >> t; \
    while (t--)
#define ll long long
#define ld long double
#define endl "\n"

const ld PI = acos(-1);
const int N = 1e5 + 10;
const int MOD = 1e9 + 7;
const int mod1 = 998244353;
const ll INF = 2e18;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);cout.tie(nullptr);cerr.tie(nullptr);
    //test
    {
        vector <string> v;
        int n,m;cin>>n>>m;
        for(int i=0;i<n;i++){
            string s;cin>>s;
            v.emplace_back(s);
        }
        sort(v.begin(),v.end());
        v.resize(unique(v.begin(),v.end())-v.begin());
        bitset <1000> ok;
        for(auto x:v){
            for(int i=0;i<m;i++){
                if(x[i]=='#'){
                    if(ok[i]){
                        return cout<<"No",0;
                    }
                    ok[i]=1;
                }
            }
        }
        cout<<"Yes";
    }
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

int main() {
    ios_base::sync_with_stdio(false);
    int n, m;
    cin >> n >> m;
    vector<string> data(n);
    for (auto &x : data) {
        cin >> x;
    }

    bool flag = true;
    for (int i = 0; i < n && flag; ++i) {
        vector<int> can_be;
        for (int j = 0; j < m; ++j) {
            if (data[i][j] == '#') {
                can_be.push_back(j);
            }
        }

        vector<int> good_rows;
        vector<int> my_rows;

        for (int j = 0; j < can_be.size(); ++j) {
            if (!flag) {
                break;
            }
            int col = can_be[j];
            for (int r = i + 1; r < n; ++r) {
                if (data[r][col] != '#') {
                    continue;
                }
                if (j == 0) {
                    good_rows.push_back(r);
                }
                my_rows.push_back(r);

            }
            if (my_rows != good_rows) {
                flag = false;
            }
            my_rows.clear();
        }
        if (flag) {
            vector<int> good_columns;
            for (int j = 0; j < good_rows.size(); ++j) {
                for (int k = 0; k < m; ++k) {
                    if (data[good_rows[j]][k] == '#') {
                        good_columns.push_back(k);
                    }
                }
                if (good_columns != can_be) {
                    flag = false;
                    break;
                }
                good_columns.clear();
            }
        }
    }
    if (flag) {
        cout << "Yes\n";
    } else {
        cout << "No\n";
    }
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

int main() {
    ios_base::sync_with_stdio(false);
    int n, m;
    cin >> n >> m;
    vector<string> data(n);
    for (auto &x : data) {
        cin >> x;
    }

    bool flag = true;
    for (int i = 0; i < n && flag; ++i) {
        vector<int> can_be;
        for (int j = 0; j < m; ++j) {
            if (data[i][j] == '#') {
                can_be.push_back(j);
            }
        }
        vector<int> good_rows;
        vector<int> my_rows;
        for (int j = 0; j < can_be.size(); ++j) {
            if (!flag) {
                break;
            }
            int col = can_be[j];
            for (int r = i + 1; r < n; ++r) {
                if (data[r][col] != '#')
                    continue;
                if (j == 0) {
                    good_rows.push_back(r);
                }
                my_rows.push_back(r);

            }
            if (my_rows != good_rows) {
                flag = false;
            }
            my_rows.clear();
        }
    }
    if (flag) {
        cout << "Yes\n";
    } else {
        cout << "No\n";
    }
    return 0;
}


#include <cstdlib>
#include <csignal>
#include <csetjmp>
#include <cstdarg>
#include <typeinfo>
#include <typeindex>
#include <type_traits>
#include <bitset>
#include <functional>
#include <utility>
#include <ctime>
#include <chrono>
#include <cstddef>
#include <initializer_list>
#include <tuple>
#include <any>
#include <optional>
#include <variant>
#include <new>
#include <memory>
#include <scoped_allocator>
#include <climits>
#include <cfloat>
#include <cstdint>
#include <cinttypes>
#include <limits>
#include <exception>
#include <stdexcept>
#include <cassert>
#include <system_error>
#include <cerrno>
#include <cctype>
#include <cwctype>
#include <cstring>
#include <cwchar>
#include <string>
#include <string_view>
#include <array>
#include <vector>
#include <deque>
#include <list>
#include <forward_list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <stack>
#include <queue>
#include <iterator>
#include <algorithm>
#include <cmath>
#include <complex>
#include <random>
#include <numeric>
#include <iosfwd>
#include <ios>
#include <istream>
#include <ostream>
#include <iostream>
#include <fstream>
#include <sstream>
#include <strstream>
#include <iomanip>
#include <streambuf>
#include <cstdio>
#include <locale>
#include <clocale>
#include <codecvt>
#include <regex>
#include <atomic>
#include <thread>
#include <mutex>
#include <shared_mutex>
#include <future>
#include <condition_variable>

#define forn(i, n) for (int i = 0; i < int(n); i++)
#define nfor(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 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 x first
#define y second

using namespace std;

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

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; }

template<typename A, typename B> inline ostream& operator<< (ostream& out, const pair<A, B>& p) { return out << "(" << p.x << ", " << p.y << ")"; }
template<typename T> inline ostream& operator<< (ostream& out, const vector<T>& a) { out << "["; forn(i, sz(a)) { if (i) out << ','; out << ' ' << a[i]; } return out << " ]"; }
template<typename T> inline ostream& operator<< (ostream& out, const set<T>& a) { return out << vector<T>(all(a)); }
template<typename X, typename Y> inline ostream& operator<< (ostream& out, const map<X, Y>& a) { return out << vector<pair<X, Y>>(all(a)); }
template<typename T> inline ostream& operator<< (ostream& out, const pair<T*, int>& a) { return out << vector<T>(a.x, a.x + a.y); }

inline ld gett() { return ld(clock()) / CLOCKS_PER_SEC; }

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

#ifdef SU1
//#define GEN
#ifndef GEN
#define LOG
#endif
#endif

const int N = 55;

int n, m;
char a[N][N];

bool read() {
  if (!(cin >> n >> m)) return false;
  forn(i, n) assert(scanf("%s", a[i]) == 1);
  return true;
}

void solve() {
  forn(i1, n)
  fore(i2, i1 + 1, n)
    forn(j1, m)
    fore(j2, j1 + 1, m) {
      int cnt = 0;
      for (int j : {j1, j2})
        for (int i : {i1, i2})
          cnt += a[i][j] == '#';
      if (cnt == 3) {
        puts("No");
        return;
      }
    }
  puts("Yes");
}

int main() {
#ifdef SU1
  assert(freopen("input.txt", "rt", stdin));
  //assert(freopen("output.txt", "wt", stdout));
#endif

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

  while (read()) {
    ld stime = gett();
    solve();
#ifdef SU1
    cerr << "Time: " << gett() - stime << endl;
#endif
    //break;
  }

  return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define M 1000000007
#define ll long long
#define pb push_back
#define F first
#define S second
#define vl vector<ll>
#define vvl vector<vl>
#define pii pair<int,int>
#define pll pair<ll,ll>

int main()
{
	int n,m;
	cin >> n >> m;
	vector<string> a(n);
	for(int i=0;i<n;i++) cin >> a[i];

	for(int i=0;i<n;i++)
	{
		for(int j=i+1;j<n;j++)
		{
			bool f1=false;
			bool f2=false;
			for(int k=0;k<m;k++)
			{
				if(a[i][k]=='#' && a[j][k]=='#') f1=true;
				if( (a[i][k]=='#' && a[j][k]=='.') || (a[i][k]=='.' && a[j][k]=='#'))
				{
					f2=true;
				}
			}
			if(f1 && f2)
			{
				cout << "No" << endl; return 0;
			}
		}
	}

	cout << "Yes" << endl;
}


/*
	"We know what we are, but know not what we may be."
*/

#include <bits/stdc++.h>

using namespace std;
using ll = long long;

const int N = 2e5 + 3;
const int M = 1e6 + 7;
const long long MOD = 1e9 + 7;
const long long INF = 1e18 + 9;
const int SM = 1e3 + 5;
const int logN = 20, BL = 400;
const double EPS = 3e-16;

/*
	"You never know how strong you are until being strong is the only choice you have."
*/

int main(){
//  freopen(".in", "r", stdin);
//  freopen(".out", "w", stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(0), cout.tie(0);

/*
	"With self-discipline most anything is possible."
*/

	long long n, m; cin >> n >> m;

	bitset<SM> a[SM];
	for(long long i = 0; i < n; i++){
		for(long long j = 0; j < m; j++){
			char c; cin >> c;
			a[i][j] = (c == '#');
		}
	}

	for(long long i = 0; i < n; i++){
		for(long long j = i + 1; j < n; j++){
			bitset<SM> b;
			if(a[i] != a[j] && (a[i] & a[j]) != b){
				return cout << "No", 0;
			}
		}
	}

	cout << "Yes";
	return 0;
}

/*
	"Reach for it. Push yourself as far as you can."
*/


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

char s[maxn];
bool vit[maxn][maxn];
vector<pair<int, int> > v;

int main() {
	int r, c, i, k;
	scanf("%d %d\n", &r, &c);
	for (i = 0; i < r; i++) {
		scanf("%s", s);
		for (k = 0; k < c; k++)
			if (s[k] == '#') {
				vit[i][k] = true;
				v.push_back(make_pair(i, k));
			}
	}
	for (i = 0; i < v.size(); i++)
		for (k = i + 1; k < v.size(); k++)
			if (v[i].first != v[k].first && v[i].second != v[k].second && (!vit[v[i].first][v[k].second] || !vit[v[k].first][v[i].second])) {
				printf("No");
				return 0;
			}
	printf("Yes");
	return 0;
}


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

char s[maxn];
bool vit[maxn][maxn];
vector<pair<int, int> > v;

int main() {
	int r, c, i, k;
	scanf("%d %d\n", &r, &c);
	for (i = 0; i < r; i++) {
		scanf("%s", s);
		for (k = 0; k < c; k++)
			if (s[k] == '#') {
				vit[i][k] = true;
				v.push_back(make_pair(i, k));
			}
	}
	for (i = 0; i < v.size(); i++)
		for (k = i + 1; k < v.size(); k++)
			if (v[i].first != v[k].first && v[i].second != v[k].second && (vit[v[i].first][v[k].second] ^ vit[v[k].first][v[i].second])) {
				printf("No");
				return 0;
			}
	printf("Yes");
	return 0;
}


#include <iostream>
#include <array>
#include <set>
#include <vector>
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
//#include "bits/stdc++.h"

#define fore(i,a,b) for(int i = a; i < (b); i++)
#define fr(i,a,b) for(int i = a - 1; i >= b; i--)
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define TH 200005
#define FH 400005

using namespace std;

typedef long long ll;
typedef pair<ll, ll> pr;
typedef pair<pair<ll, ll>, ll> spr;
//typedef pair<pair<ll, ll>, vector<int>> wtf;

int n, m;
char** table;
vector<int> col;
vector<int> ucol;
vector<int> urow;
bool flag = true;

inline void read()
{
	cin >> n >> m;
	table = new char*[n];
	fore(i,0,n)
	{
		table[i] = new char[m];
		fore(j,0,m)
			cin >> table[i][j];
	}
}

bool findInVector(int i, char v)
{
	if (v == 'r')
	{
		fore(k,0,urow.size())
			if (urow[k] == i) return true;
	}
	else
		fore(k,0,ucol.size())
			if (ucol[k] == i) return true;
	return false;
}
void findInRow(int i, int j)
{
	fore(l,j,m)
		if (table[i][l] == '#')
		{
			if (findInVector(l, 'c'))
			{
				cout << "No";
				exit(0);
			}
			col.push_back(l);
			ucol.push_back(l);
			table[i][l] = '.';
		}
}

void findAll(int i, int j)
{
	if (i == n - 1) return;
	fore(k,i + 1,n)
	{
		if (table[k][j] == '#')
		{
			if (findInVector(k, 'r'))
		    {
					cout << "No";
					exit(0);
			}
			fore(z,0,col.size())
			{
				if (table[k][col[z]] != '#')
				{
					flag = false;
					return;
				}
				else
					table[k][col[z]] = '.';
			}
			urow.push_back(k);
		}
	}
}

inline void solve()
{
	fore(i,0,n)
	{
		fore(j,0,m)
		{
			if (table[i][j] == '#')
			{
				if (findInVector(i, 'r'))
				{
					cout << "No";
					exit(0);
			    }
				urow.push_back(i);
				findInRow(i, j);
				findAll(i, j);
				if (!flag)
				{
					cout << "No";
					exit(0);
			    }
				break;
			}
		}
		col.clear();
	}
	cout << "Yes";
}

int main()
{
	fast;
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
	read();
	solve();
}


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

using namespace std;

#define endl '\n'
#define lol long long
#define fi(i, a, b) for (int i = (a); i < (b); i++)
#define debug(x) cout << "[" << __LINE__ << "] " << #x << ": " << (x) << endl
#define pl pair<lol, lol>

vector< vector<bool> > s;

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

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

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

    s.resize(n);
    fi(i, 0, n)
    {
        s[i].resize(m);
    }

    fi(i, 0, n)
    {
        fi(j, 0, m)
        {
            char a;
            cin >> a;
            s[i][j] = a == '#';
        }
    }

    fi(i, 0, n)
    {

        set<int> first;
        fi(j, 0, m)
        {
            if (s[i][j])
                first.insert(j);
        }

        fi(ii, i + 1, n)
        {

            set<int> second;
            fi(j, 0, m)
            {
                if (s[ii][j])
                    second.insert(j);
            }

            set<int> sum;

            fi(j, 0, first.size())
                sum.insert(*next(first.begin(), j));

            fi(j, 0, second.size())
                sum.insert(*next(second.begin(), j));

            if(sum.size() == first.size() + second.size()) continue;
            if(sum.size() == first.size() && sum.size() == second.size()) continue;
            //else
            cout << "No" << endl;
            return 0;
        }
    }

    cout << "Yes" << endl;
}


//mystical mosiac
#include <bits/stdc++.h>
#define fast ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define ll long long
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define pi pair<int,int>
#define mod 1000000007
#include<stdio.h>
using namespace std;
int main()
{
	int n,m,i,j;
	cin>>n>>m;
	char a[n][m];
	for(i=0;i<n;i++)
	{
		for(j=0;j<m;j++)
		{
			cin>>a[i][j];
		}
	}
	int flag=0,k;
	for(i=0;i<n-1;i++)
	{
		for(k=i+1;k<n;k++)
		{
			flag=0;
			for(j=0;j<m;j++)
			{
				if(a[i][j]!=a[k][j])
				{
					flag=1;
				}
				else if(flag==1&&a[i][j]=='#')
				{
					cout<<"NO\n";
					return 0;
				}
			}
		}
	}
	cout<<"YES\n";
}


//mystical mosiac
#include <bits/stdc++.h>
#define fast ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define ll long long
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define pi pair<int,int>
#define mod 1000000007
#include<stdio.h>
using namespace std;
int main()
{
	int n,m,i,j;
	cin>>n>>m;
	char a[n][m];
	for(i=0;i<n;i++)
	{
		for(j=0;j<m;j++)
		{
			cin>>a[i][j];
		}
	}
	int flag=0,k;
	for(i=0;i<n-1;i++)
	{
		for(k=i+1;k<n;k++)
		{
			flag=0;
			for(j=0;j<m;j++)
			{
				if(a[i][j]!=a[k][j])
				{
					if(flag==2)
					{
						cout<<"NO";
						return 0;
					}
					flag=1;
				}
				else if(flag==1&&a[i][j]=='#')
				{
					cout<<"NO\n";
					return 0;
				}
				else if(flag==0&&a[i][j]=='#')
				{
					flag=2;
				}
			}
		}
	}
	cout<<"YES\n";
}


#include <bits/stdc++.h>

using namespace std;

const int MAXN = 200;
vector<int> g[MAXN], comp;
bool used[MAXN];
set< pair<int, int> > ed;
int n, m;

void dfs(int v) {
	used[v] = true;
	comp.push_back(v);
	for (auto to : g[v]) {
		if (!used[to])
			dfs(to);
	}
}

void find_comps() {
	for (int i = 0; i < n + m; ++i)
		used[i] = false;
	for (int i = 0; i < n + m; ++i)
		if (!used[i]) {
			comp.clear();
			dfs(i);
			for (auto u : comp) {
                for (auto v : comp) {
                    if (u < n && v >= n) {
                        if (!ed.count(make_pair(u, v))) {
                            cout << "No";
                            exit(0);
                        }
                    }
                }
			}
		}
}

int main() {
    ios::sync_with_stdio(false);
    cin >> n >> m;
    char c;
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < m; j++) {
            cin >> c;
            if (c == '#') {
                g[i].push_back(n + j);
                g[n + j].push_back(i);
                ed.insert(make_pair(i, n + j));
            }
        }
    }
    find_comps();
    cout << "Yes";
    return 0;
}


#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx")
using namespace std;

using ll = long long;
using ull = unsigned long long;
using ld = long double;

#define forn(i, a, n) for (int i = (int)(a); i < (int)(n); ++i)
#define ford(i, a, n) for (int i = (int)(n) - 1; i >= (int)(a); --i)
#define fore(i, a, n) for (int i = (int)(a); i <= (int)(n); ++i)
#define all(a) (a).begin(), (a).end()
#define fs first
#define sn second
#define trace(a)\
    for (auto i : a) cerr << i << ' ';\
    cerr << '\n'
#define eb emplace_back

#ifndef M_PI
const ld M_PI = acos(-1.0);
#endif

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

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

template<typename T, typename S>
istream& operator>> (istream& in, pair<S, T>& p) {
    in >> p.fs >> p.sn;
    return in;
}
template<typename T, typename S>
ostream& operator<< (ostream& out, pair<S, T>& p) {
    out << p.fs << ' ' << p.sn << ' ';
    return out;
}

template<typename T>
istream& operator>> (istream& in, vector<T>& v) {
    for (T& x : v) in >> x;
    return in;
}
template<typename T>
ostream& operator<< (ostream& out, vector<T>& v) {
    for (T& x : v) out << x << ' ';
    return out;
}

const ld eps = 1e-9;
const int INF = 2000000000;
const ll LINF = 1ll * INF * INF;
const ll MOD = 1000000007;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    srand((unsigned)chrono::high_resolution_clock::now().time_since_epoch().count());
    int n, m;
    cin >> n >> m;
    vector<ll> a(n);
    forn(i, 0, n) {
        string s;
        cin >> s;
        forn(j, 0, m)
            if (s[j] == '#')
                a[i] ^= (1ll << j);
    }
    forn(i, 0, n) forn(j, 0, n)
        if (a[i] != a[j] && (a[i] & a[j])) {
            cout << "No\n";
            return 0;
        }
    cout << "Yes\n";
}


#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx")
using namespace std;

using ll = long long;
using ull = unsigned long long;
using ld = long double;

#define forn(i, a, n) for (int i = (int)(a); i < (int)(n); ++i)
#define ford(i, a, n) for (int i = (int)(n) - 1; i >= (int)(a); --i)
#define fore(i, a, n) for (int i = (int)(a); i <= (int)(n); ++i)
#define all(a) (a).begin(), (a).end()
#define fs first
#define sn second
#define trace(a)\
    for (auto i : a) cerr << i << ' ';\
    cerr << '\n'
#define eb emplace_back

#ifndef M_PI
const ld M_PI = acos(-1.0);
#endif

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

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

template<typename T, typename S>
istream& operator>> (istream& in, pair<S, T>& p) {
    in >> p.fs >> p.sn;
    return in;
}
template<typename T, typename S>
ostream& operator<< (ostream& out, pair<S, T>& p) {
    out << p.fs << ' ' << p.sn << ' ';
    return out;
}

template<typename T>
istream& operator>> (istream& in, vector<T>& v) {
    for (T& x : v) in >> x;
    return in;
}
template<typename T>
ostream& operator<< (ostream& out, vector<T>& v) {
    for (T& x : v) out << x << ' ';
    return out;
}

const ld eps = 1e-9;
const int INF = 2000000000;
const ll LINF = 1ll * INF * INF;
const ll MOD = 1000000007;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    srand((unsigned)chrono::high_resolution_clock::now().time_since_epoch().count());
    int n, m;
    cin >> n >> m;
    vector<ll> a(n);
    forn(i, 0, n) {
        string s;
        cin >> s;
        forn(j, 0, m)
            if (s[j] == '#')
                a[i] ^= (1 << j);
    }
    forn(i, 0, n) forn(j, 0, n)
        if (a[i] != a[j] && (a[i] & a[j])) {
            cout << "No\n";
            return 0;
        }
    cout << "Yes\n";
}


//BISMILLAHIR-RAH-MANIR-RAHIM.
//ABU AYUB MD AHMADUL(CEO-PEREGRINE SPHERE).
//FORMER CEO-SPACEH(2019).
//DEPT.OF CSE,SUST//2018-19.
//------------------------------------------\\
//PRE-CODE========>
#include<iostream>
#include<bits/stdc++.h>
using namespace std;
#include<vector>
#include<math.h>
#include<numeric>
#include<stack>
#include<queue>
#include<string>
#include<algorithm>
#include<map>
#define mp make_pair
#define ins insert
#define lli long long int
#define ll long long
#define pb push_back
#define loop1(i,l,n) for(i=l;i<=n;i++)
#define loop0(i,l,n) for(i=l;i<n;i++)
#define inf (1<<28)
#define pi 3.1415926536
const int MAX=1e6+9;
set<int>ist;
map<string,int>msi;
map<string,string>mss;
map<int,string>mis;
map<int,int>mii;
pair<int,int>pii;
vector<int>v;
vector<pair<int,int> >vv;
int cc[]= {1,-1,0,0};
int rr[]= {0,0,1,-1};
//BIPARTITE GRAPH FUCTION========>
/*
int cnt[2];
int vertices[MAX];
void Bipartite(int node,int pnode,int color)
{
    cnt[color]++;
    for (int i=0;i<vertices[node].size();i++)
    {
        if (vertices[node][i]!=pnode)
        {
            Bipartite(vertices[node][i],node,!color);
        }

    }
}
*/
//REAL TIME BINARY SERACH FUNCTION========>
/*
int Bsearch(int left,int right,int query,int n)
{
    int mid=left+(right-left)/2;
    if(query<mid)
    {
        return Bsearch(left,mid-1,query,n);
    }
    else if(query>mid)
    {
        return Bsearch(mid+1,right,query,n-1);
    }
    else
    {
        return n;
    }
}
*/
//DECIMAL TO BINARY DECODING========>
/*
ll D2B(ll dec)
{
    ll digit[32]={};
    ll i = 0;
    while (dec > 0)
    {
        [i] = n % 2;
        n = n / 2;
        i++;
    }

}
*/
//BINARY TO DECIMAL DECODING========>
/*
ll b2d(ll bin)
{
    ll digit,sum=0,h=0;
    while(bin!=0)
    {
        digit=bin%10;
        sum+=digit*pow(2,h++);
        bin/=10;
    }
    return sum;
}
*/
//DFS FUNCTION=========>
/*
int visited[MAX];
vector<int>adj[MAX];
int weight[MAX];
void dfs(int v)
{
    visited[v] = 1;
    for (auto j: adj[v])
    {
        if (!visited[j])
        {
            dfs(j);
        }
    }
}
*/
//------------------------------------------\\
//LAUNCHING SHARK-20========>
set<string>ss;
void LIFT_OFF_SHARK_AP20()
{
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    int t;
    int n;
    cin >> n;
    int m;
    cin >> m;
    for (int i=0; i<n; i++)
    {
        string sp;
        cin >> sp;
        ss.insert(sp);
    }
    for (int i=0; i<m; i++)
    {
        int col=0;
        for (auto &it:ss)
        {
            if (it[i]=='#')
            {
                col++;
            }
        }
        if (col>1)
        {
            cout << "NO"<<endl;
            return;
        }
    }
    cout << "Yes";
    return;

}
//MAIN FUNCTION========>
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    LIFT_OFF_SHARK_AP20();

    return 0;
}
//------------------------------------------\\
//ABOUT THE SERIES========>
//THE BULL SHARK SERIES-(APRIL-2020).
//SPONSERED BY FASTEX AND SPAIT(CEO-SAMIA PREITY).
//CONTROLLER=>NASRULLAH SAMI(CEO-FALCON AXIS).
//ADVISOR=>ALFEH SANI(CEO-BRICK-TECH).
//CO-CHIEF ADVISOR=>G.M NAYEEM(CEO-TECH FRIGATE).
//PRESIDENT=>S.H RONY(CEO-BINARY SKY).


#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,t;
  cin>>n>>t;
  map< string,pair<vector<int> , vector<int> > > m;
  bool row[n];
  for(int i=0;i<n;i++)row[i]=false;
  bool col[t];
  for(int i=0;i<t;i++)col[i]=false;
  string s;
  for(int i=0;i<n;i++){
    cin>>s;
    m[s].first.push_back(i);
    for(int j=0;j<t;j++){
      if(s[j]=='#'){
          if(find(m[s].second.begin(),m[s].second.end(),j)==m[s].second.end())
        m[s].second.push_back(j);
      }
    }
  }
//   cout<<m.size();
//   for(auto it=m.begin();it!=m.end();it++){
//       for(int i=0;i<it->second.second.size();i++)cout<<it->second.second[i];
//       cout<<endl;
//   }
  for(auto it=m.begin();it!=m.end();it++){
    for(int i=0;i<it->second.first.size();i++){
      if(!row[it->second.first[i]])row[it->second.first[i]]=true;
      else {
        //   cout<<"problem in row";
          cout<<"NO";return 0;}
    }
    for(int i=0;i<it->second.second.size();i++){
      if(!col[it->second.second[i]])col[it->second.second[i]]=true;
      else {
        //   cout<<"problem in colum";
          cout<<"NO";return 0;}
    }
  }
  cout<<"YES";
  return 0;
}


//Author: Fuadul Hasan(fuadul202@gmail.com)
#include<bits/stdc++.h>
using namespace std;

#define ll long long
const int N   = 2e2 + 5;
int dp[N][N];

int dx[] = {1,0,-1,0};
int dy[] = {0,1,0,-1};
bool ck(int x,int y){
	for(int i=0;i<4;i++){
		int nx = x+dx[i];
		int ny = y+dy[i];
		if(dp[nx][ny])return true;
	}
	return false;
}

int main(){

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

	string s[n];
	for(int i=0;i<n;i++){
		cin>>s[i];
		for(int j=1;j<=m;j++){
			if(s[i][j-1] == '.')dp[i+1][j] = 0;
			else dp[i+1][j] = 1;
		}
	}

	for(int i=1;i<n;i++){
		for(int j=1;j<m;j++){
			if(dp[i][j] and ck(i,j)){
				cout<<"NO"<<endl;
				return 0;
			}
		}
	}

	cout<<"YES"<<endl;

	return 0;
}


//Author: Fuadul Hasan(fuadul202@gmail.com)
#include<bits/stdc++.h>
using namespace std;

#define ll long long
const int N   = 2e2 + 5;
int dp[N][N];
int n,m;

int dx[] = {1,0,-1,0};
int dy[] = {0,1,0,-1};
bool ck(int x,int y){
	for(int i=0;i<4;i++){
		int nx = x+dx[i];
		int ny = y+dy[i];
		if(dp[nx][ny])return true;
	}
	return false;
}

bool ck1(int x,int y){
	for(int i=1;i<=m;i++){
		if(dp[x][i] or dp[y][i]){
			return false;
		}
	}
	return true;
}

bool ck2(int x,int y){
	for(int i=1;i<=n;i++){
		if(dp[i][x] or dp[i][y]){
			return false;
		}
	}
	return true;
}

int main(){

	cin>>n>>m;

	string s[n];
	for(int i=0;i<n;i++){
		cin>>s[i];
		for(int j=1;j<=m;j++){
			if(s[i][j-1] == '.')dp[i+1][j] = 0;
			else dp[i+1][j] = 1;
		}
	}

	for(int i=1;i<n;i++){
		for(int j=1;j<m;j++){
			if(dp[i][j] and ck(i,j)){
				cout<<"NO"<<endl;
				return 0;
			}
		}
	}

	for(int i=1;i<n;i++){
		for(int j=i+1;j<=n;j++){
			if(ck1(i,j)){
				cout<<"NO"<<endl;
				return 0;
			}
		}
	}
	for(int i=1;i<=m;i++){
		for(int j=i+1;j<=m;j++){
			if(ck2(i,j)){
				cout<<"NO"<<endl;
				return 0;
			}
		}
	}

	cout<<"YES"<<endl;

	return 0;
}


//Author: Fuadul Hasan(fuadul202@gmail.com)
#include<bits/stdc++.h>
using namespace std;

#define ll long long
const int N   = 2e2 + 5;
int dp[N][N];
int n,m;

int dx[] = {1,0,-1,0};
int dy[] = {0,1,0,-1};
bool ck(int x,int y){
	for(int i=0;i<4;i++){
		int nx = x+dx[i];
		int ny = y+dy[i];
		if(dp[nx][ny])return true;
	}
	return false;
}

bool ck1(int x,int y){
	for(int i=1;i<=m;i++){
		if(dp[x][i] != dp[y][i]){
			return false;
		}
	}
	return true;
}

bool ck2(int x,int y){
	for(int i=1;i<=m;i++){
		if(dp[x][i] and dp[y][i]){
			return false;
		}
	}
	return true;
}

int main(){

	cin>>n>>m;

	string s[n];
	for(int i=0;i<n;i++){
		cin>>s[i];
		for(int j=1;j<=m;j++){
			if(s[i][j-1] == '.')dp[i+1][j] = 0;
			else dp[i+1][j] = 1;
		}
	}

	for(int i=1;i<n;i++){
		for(int j=i+1;j<=n;j++){
			if(!ck1(i,j) and !ck2(i,j)){
				cout<<"NO"<<endl;
				return 0;
			}
		}
	}

	cout<<"YES"<<endl;

	return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define FS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long int
#define MAX_INT 100000
#define ld long double
#define pb push_back
#define pu push
#define bp __builtin_popcount
#define vsz(v) cout<<v.size()<<endl;
#define printv(v) for(ll i=0;i<v.size();i++)cout<<v[i]<<" "; cout<<endl;
#define printa(a,n) for(ll i=0;i<n;i++)cout<<a[i]<<" ";cout<<endl;
#define printrv(v) for(ll i=v.size()-1;i>=0;i--)cout<<v[i]<<" "; cout<<endl;
#define printvpair(v) for(ll i=0;i<v.size();i++)cout<<v[i].first<<" "<<v[i].second<<endl;
#define sz size()
#define ff first
#define ss second
#define vll vector<ll>
#define vbool vector<bool>
#define vpll vector<pair<ll,ll>>
#define vvpll vector<vector<pair<ll,ll>>>
#define qll queue<ll>
#define dqll deque<ll>
#define pll pair<ll,ll>
#define vllv vector<vector<ll>>
#define vstr vector<string>
#define setpri(x) cout<<setprecision(x);
#define all(v) v.begin(),v.end()
#define allr(v) v.rbegin(),v.rend()
#define scana(a,n) for(ll i=0;i<n;i++)cin>>a[i];
#define inf 1000000000000
#define yes cout<<"YES"<<endl
#define no cout<<"NO"<<endl
#define yesr {cout<<"YES"<<endl;return;}
#define nor {cout<<"NO"<<endl;return;}
ll MOD=1e9+7;
ll ceil1(ll n,ll x){if(n%x==0)return n/x; else return (n/x)+1;}
ll gcd(ll a,ll b){return __gcd(a,b);}
ll lcm(ll a,ll b){return (max(a,b)/gcd(a,b))*min(a,b);}
ll pow1(ll n,ll k,ll mm){
    if(k==0)return 1;
    if(k%2==0)return (pow1((n%mm)*(n%mm),k/2,mm))%mm;
    return ((n%mm)*(pow1((n%mm)*(n%mm),k/2,mm)%mm))%mm;
}
ll pow2(ll n,ll k){ll ans=1;
	while(k>0){
        if(k%2==1)ans=ans*n;n=n*n;k/=2;
    }return ans;
}
ll modinv(ll A,ll M){return pow1(A,M-2,M);}
ll fact(ll n){ll s=1; for(ll i=1;i<=n;i++)s*=i; return s;}
ll factmod(ll n,ll mod){ll s=1; for(ll i=1;i<=n;i++){s*=i;s%=mod;} return s;}
vll fact1tonmod(ll n,ll mod){vll  ans(n+1);ans[0]=ans[1]=1;
	for(ll i=2;i<=n;i++)ans[i]=(ans[i-1]*i)%mod;
	return ans;
}
ll ncrmod(ll n,ll r,ll mod){
	ll ans=((((factmod(n,mod)%mod)*(modinv(factmod(r,mod),mod)%mod))%mod)*(modinv(factmod(n-r,mod),mod)))%mod;
	return ans;
}
ll ncr(ll n,ll r){if(n==1 || r==0)return 1;if(r>n/2)r=n-r;
	ll ans=1;for(ll i=1;i<=r;i++){ans=((ans * n )/i);n--;}return ans;
}
ll ncrsum(ll n,ll r, ll mod){
	if(n==1 || r==0)return 1;
	ll ans=1,sum=1;for(ll i=1;i<=r;i++){ans=(((ans * n )/i)%mod);n--;sum+=ans;sum%=mod;}return sum;
}
bool isprime(ll n){if(n==1 || (n!=2 && n%2==0))return false; if(n==2)return true;
		for(ll i=3;i<=sqrt(n);i+=2)if(n%i==0)return false; return true; }
vll createprime(ll n){
	vector<bool> prime(n+1,true);vll ans;;prime[0]=prime[1]=false;
	for(ll i=2;i*i<=n;i++)if(prime[i])for(ll j=i*i;j<=n;j+=i)prime[j]=false;
	for(ll i=2;i<=n;i++)if(prime[i])ans.pb(i);
	return ans;
}
vbool createprimebool(ll n){
	vector<bool> prime(n+1,true);prime[0]=prime[1]=false;
	for(ll i=2;i*i<=n;i++)if(prime[i])for(ll j=i*i;j<=n;j+=i)prime[j]=false;
	return prime;
}
vll factor(ll n){
	vll ans;
	if(n>0)ans.pb(1);if(n==2)ans.pb(2);
	for(ll i=2;i*i<=n;i++){if(n%i==0){ans.pb(i);if(n/i!=i)ans.pb(n/i);}}if(n>2)ans.pb(n);
	return ans;
}
ll numoffactor(ll n){ return factor(n).sz;}
bool func(pair<ll,ll> &a,pair<ll,ll> &b ){
	if(a.ff != b.ff)return a.ff < b.ff;
	return a.ss > b.ss;
}
bool chk(ll i,ll j,ll k){
	ll a[3]={i,j,k};
	sort(a,a+3);
	return a[0]+a[1]>a[2];
}
void solve(){
	ll i,j,k,n,m,x,y,z,d,l,r;
	cin>>n>>m;
	vstr s(n);
	ll sum=0;
	for(i=0;i<n;i++){
		cin>>s[i];
		for(j=0;j<m;j++){
			if(s[i][j])sum++;
		}
	}
	// cout<<sum<<endl;
	for(i=0;i<n;i++){
		vll v;
		for(j=0;j<m;j++){
			if(s[i][j]=='#')v.pb(j);
		}
		vll v1;
		if(v.sz>0){
		for(j=0;j<n;j++){
			if(s[j][v[0]]=='#')v1.pb(j);
		}
		}
		for(j=0;j<v1.sz;j++){
			if(s[v1[j]]!=s[v1[0]]){
				cout<<"NO";
				return;
			}
		}
		for(j=0;j<v.sz;j++){
			for(k=0;k<n;k++){
				if(s[k][v[0]]!=s[k][v[j]]){
					cout<<"No";
					return;
				}
			}
		}
		// printv(v);
		// printv(v1);
	}
	cout<<"YEs";

}
int main(){
	FS;
	ll i,j,k,n,m,x,y,z,q;
	q=1;
	// cin>>q;
	while(q--){
		solve();
	}
	return 0;
}


#include <iostream>
#include <cmath>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <map>
#include <unordered_set>

using namespace std;

char graph[60][60];
int main()
{
	int n, m;
	char t;
	scanf("%d%d", &n, &m);
	getchar();
	for (int i = 0; i<n; i++)
		for (int j = 0; j<=m; j++)
			scanf("%c", &graph[i][j]);
	unordered_set<int> sett;
	bool ans = true;
	for (int i = 0; i<m; i++)
	{
		unordered_set<int> tocompare;
		for (int j = 0; j<n; j++)
		{
			if (graph[j][i] == '#')
			{
				tocompare.insert(j);
			}
		}
		// find black in column
		if (tocompare.size() == 0 || tocompare.size() == 1)
		{
			for (int row : tocompare)
				sett.insert(row);
			continue;
		}
		vector<int> cmp;
		int havecmp = 0;
		bool fail = false;
		for (int row : tocompare)
		{
			if (sett.find(row) != sett.end())
			{
				if (havecmp == -1)
				{
					fail = true;
					break;
				}
				havecmp = 1;
			}
			else
			{
				if (havecmp == 1)
				{
					fail = true;
					break;
				}
				havecmp = -1;
			}
		}
		// judge if some of column are compared but some not
		if (fail)
		{
			ans = false;
			break;
		}
		if (havecmp == 1)
			continue;
		//if all of column haven't been compared,check them
		fail = false;
		for (int row : tocompare)
			sett.insert(row);
		for (int c = 0; c < m; c++)
		{
			int fir = 0;
			for (int row : tocompare)
			{
				if (fir == 0)
					fir = graph[row][c];
				else if (graph[row][c] != fir)
				{
					fir = -1;
					fail = true;
					break;
				}
			}
			if (fir == -1)
				break;
		}
		if (fail)
		{
			ans = false;
			break;
		}
	}
	if (ans)
		printf("Yes\n");
	else
		printf("No\n");
	return 0;
}


#include <iostream>
#include <cmath>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <map>
#include <unordered_set>

using namespace std;

char graph[60][60];
int main()
{
	int n, m;
	char t;
	scanf("%d%d", &n, &m);
	getchar();
	for (int i = 0; i<n; i++)
		for (int j = 0; j<=m; j++)
			scanf("%c", &graph[i][j]);
	unordered_set<int> sett;
	bool ans = true;
	for (int i = 0; i<m; i++)
	{
		unordered_set<int> tocompare;
		for (int j = 0; j<n; j++)
		{
			if (graph[j][i] == '#')
			{
				tocompare.insert(j);
			}
		}
		// find black in column
		if (tocompare.size() == 0 || tocompare.size() == 1)
		{
			for (int row : tocompare)
				sett.insert(row);
			continue;
		}
		vector<int> cmp;
		int havecmp = 0;
		bool fail = false;
		for (int row : tocompare)
		{
			if (sett.find(row) != sett.end())
			{
				if (havecmp == -1)
				{
					fail = true;
					break;
				}
				havecmp = 1;
			}
			else
			{
				if (havecmp == 1)
				{
					fail = true;
					break;
				}
				havecmp = -1;
			}
		}
		// judge if some of column are compared but some not
		if (fail)
		{
			ans = false;
			break;
		}
		if (havecmp == 1)
			continue;
		//if all of column haven't been compared,check them
		fail = false;
		for (int row : tocompare)
			sett.insert(row);
		for (int c = i + 1; c<m; c++)
		{
			int fir = 0;
			for (int row : tocompare)
			{
				if (fir == 0)
					fir = graph[row][c];
				else if (graph[row][c] != fir)
				{
					fir = -1;
					fail = true;
					break;
				}
			}
			if (fir == -1)
				break;
		}
		if (fail)
		{
			ans = false;
			break;
		}
	}
	if (ans)
		printf("Yes\n");
	else
		printf("No\n");
	return 0;
}


#include <iostream>
#include <cmath>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <map>
#include <unordered_set>

using namespace std;

char graph[60][60];
int type[60];
int main()
{
	int n, m;
	char t;
	scanf("%d%d", &n, &m);
	getchar();
	for (int i = 0; i<n; i++)
		for (int j = 0; j<=m; j++)
			scanf("%c", &graph[i][j]);
	unordered_set<int> sett;
	bool ans = true;
	int ptype=1;
	for (int i = 0; i<m; i++)
	{
		unordered_set<int> tocompare;
		for (int j = 0; j<n; j++)
		{
			if (graph[j][i] == '#')
			{
				tocompare.insert(j);
			}
		}
		// find black in column
		if (tocompare.size() == 0 || tocompare.size() == 1)
		{
			for (int row : tocompare)
				sett.insert(row);
			continue;
		}
		vector<int> cmp;
		int firsttype=-1;
		bool fail = false;
		for (int row : tocompare)
		{
			if(firsttype==-1)
				firsttype=type[row];
			else if(firsttype!=type[row])
			{
				fail=true;
				break;
			}
		}
		// judge if some of column are compared but some not
		if (fail)
		{
			ans = false;
			break;
		}
		if (firsttype != 0)
			continue;
		//if all of column haven't been compared,check them
		fail = false;
		for (int row : tocompare)
		{
			sett.insert(row);
			type[row]=ptype;
		}
		ptype++;
		for (int c = 0; c < m; c++)
		{
			int fir = 0;
			for (int row : tocompare)
			{
				if (fir == 0)
					fir = graph[row][c];
				else if (graph[row][c] != fir)
				{
					fir = -1;
					fail = true;
					break;
				}
			}
			if (fir == -1)
				break;
		}
		if (fail)
		{
			ans = false;
			break;
		}
	}
	if (ans)
		printf("Yes\n");
	else
		printf("No\n");
	return 0;
}