#!/usr/bin/env python3 def main(): h, w = map(int, input().split()) f = [input() for _ in range(h)] p = True for y in range(h): if f[y].count('1') in (0, w): p = False g = [''.join([f[y][x] for y in range(h)]) for x in range(w)] q = True for x in range(w): if g[x].count('1') in (0, h): q = False ans = p or q print(ans and 'YES' or 'NO') if __name__ == "__main__": main()