//prewritten code: https://github.com/antma/algo
import std.algorithm;
import std.array;
import std.conv;
import std.math;
import std.range;
import std.stdio;
import std.traits;
import core.bitop;
import std.typecons;

class LazyPropagationSegmentTree(T = int, D = int, D init = D.init) {
  immutable size_t n;
  immutable int h;
  T[] t;
  D[] d;

  abstract void calc (size_t p, int k);
  abstract void apply (size_t p, D value, int k);

  final void build (size_t l, size_t r) {
    int k = 2;
    for (l += n, r += n - 1; l > 1; k <<= 1) {
      l >>= 1;
      r >>= 1;
      foreach_reverse (i; l .. r + 1) {
        calc (i, k);
      }
    }
  }

  final void push (size_t l, size_t r) {
    int s = h, k = 1 << (h-1);
    for (l += n, r += n - 1; s > 0; --s, k >>= 1) {
      foreach (i; l >> s .. (r >> s) + 1) {
        immutable delta = d[i];
        if (delta != init) {
          apply (i << 1, delta, k);
          apply ((i << 1) | 1, delta, k);
          d[i] = init;
        }
      }
    }
  }

  this (const T[] a) {
    n = a.length;
    h = bsr (n);
    t = uninitializedArray!(T[])(n);
    t ~= a;
    d = uninitializedArray!(D[])(n);
    d[] = init;
    build (0, n);
  }
}

class AssignSumLazyPropagationSegmentTree (T = int) : LazyPropagationSegmentTree!(T, T, T.min) {
  override void calc (size_t p, int k) {
    if (d[p] == T.min) t[p] = t[p<<1] + t[(p << 1) | 1];
    else t[p] = d[p] * k;
  }

  override void apply (size_t p, T value, int k) {
    t[p] = value * k;
    if (p < n) d[p] = value;
  }

  final void assign (size_t l, size_t r, T value) {
    debug stderr.writefln ("assign (l:%d, r:%d, value:%d)", l, r, value);
    push (l, l + 1);
    push (r - 1, r);
    immutable l0 = l, r0 = r;
    int k = 1;
    for (l += n, r += n; l < r; l >>= 1, r >>= 1, k <<= 1) {
      if (l & 1) {
        apply (l++, value, k);
      }
      if (r & 1) {
        apply (--r, value, k);
      }
    }
    build (l0, l0 + 1);
    build (r0 - 1, r0);
  }

  final T sum (size_t l, size_t r) {
    push (l, l + 1);
    push (r - 1, r);
    T res;
    for (l += n, r += n; l < r; l >>= 1, r >>= 1) {
      if (l & 1) {
        res += t[l++];
      }
      if (r & 1) {
        res += t[--r];
      }
    }
    return res;
  }
  this (T[] a) {
    super (a);
  }
}

final class InputReader {
  private:
  ubyte[] p, buffer;
  bool eof;
  bool rawRead () {
    if (eof) {
      return false;
    }
    p = stdin.rawRead (buffer);
    if (p.empty) {
      eof = true;
      return false;
    }
    return true;
  }
  ubyte nextByte(bool check) () {
    static if (check) {
      if (p.empty) {
        if (!rawRead ()) {
          return 0;
        }
      }
    }
    auto r = p.front;
    p.popFront ();
    return r;
  }
  public:
  this () {
    buffer = uninitializedArray!(ubyte[])(16<<20);
  }
  bool seekByte (in ubyte lo) {
    while (true) {
      p = p.find! (c => c >= lo);
      if (!p.empty) {
        return false;
      }
      if (!rawRead ()) {
        return true;
      }
    }
  }
  template next(T) if (isSigned!T) {
    T next ()  {
      if (seekByte (45)) {
        return 0;
      }
      T res;
      ubyte b = nextByte!false ();
      if (b == 45) {
        while (true) {
          b = nextByte!true ();
          if (b < 48 || b >= 58) {
            return res;
          }
          res = res * 10 - (b - 48);
        }
      } else {
        res = b - 48;
        while (true) {
          b = nextByte!true ();
          if (b < 48 || b >= 58) {
            return res;
          }
          res = res * 10 + (b - 48);
        }
      }
    }
  }
  template next(T) if (isUnsigned!T) {
    T next () {
      if (seekByte (48)) {
        return 0;
      }
      T res = nextByte!false () - 48;
      while (true) {
        ubyte b = nextByte!true ();
        if (b < 48 || b >= 58) {
          break;
        }
        res = res * 10 + (b - 48);
      }
      return res;
    }
  }
  T[] nextA(T) (in int n) {
    auto a = uninitializedArray!(T[]) (n);
    foreach (i; 0 .. n) {
      a[i] = next!T;
    }
    return a;
  }
}

alias Q = Tuple!(int, int);

void main() {
  auto r = new InputReader ();
  const nt = r.next!uint();
  foreach (tid; 0 .. nt) {
    const n = r.next!uint();
    const nq = r.next!uint();
    r.seekByte(48);
    int[] a, b;
    foreach (i; 0 .. n) {
      const c = r.nextByte!false();
      a ~= c.to!int - 48;
    }
    r.seekByte(48);
    foreach (i; 0 .. n) {
      const c = r.nextByte!false();
      b ~= c.to!int - 48;
    }
    debug stderr.writeln(a);
    debug stderr.writeln(b);
    auto st = new AssignSumLazyPropagationSegmentTree!int(b);
    Q[] q;
    foreach (i; 0 .. nq) {
      const u = r.next!int - 1;
      const v = r.next!int;
      q ~= Q(u, v);
    }
    bool res = true;
    foreach_reverse (k, const w; q) {
      const l = w[1] - w[0];
      const h = (l - 1) / 2;
      int t = st.sum(w[0], w[1]);
      debug stderr.writefln("l = %d, r = %d, sum = %d, h = %d, l = %d", w[0], w[1], t, h, l);
      if (t <= h) {
        st.assign(w[0], w[1], 0);
      } else if (t + h >= l) {
        st.assign(w[0], w[1], 1);
      } else {
        debug stderr.writefln("FAILED: l = %d, r = %d", w[0], w[1]);
        res = false;
        break;
      }
    }
    if (res) {
      foreach (i; 0 .. n) {
        if (st.sum(i, i + 1) != a[i]) {
          res = false;
          break;
        }
      }
    }
    if (res) write("YES\n"); else write("NO\n");
  }
}

