#include <bits/stdc++.h>
using namespace std;
inline char gc() {
  static char buf[100000], *p1 = buf, *p2 = buf;
  return p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, 100000, stdin), p1 == p2)
             ? EOF
             : *p1++;
}
inline long long read() {
  char c = getchar();
  long long su = 0, f = 1;
  for (; c < '0' || c > '9'; c = getchar())
    if (c == '-') f = -1;
  for (; c >= '0' && c <= '9'; c = getchar()) su = su * 10 + c - '0';
  return su * f;
}
inline void write(long long x) {
  if (x < 0) {
    putchar('-');
    write(-x);
    return;
  }
  if (x >= 10) write(x / 10);
  putchar(x % 10 + '0');
}
inline void writesp(long long x) { write(x), putchar(' '); }
inline void writeln(long long x) {
  write(x);
  putchar('\n');
}
long long f[100005], vis[100005], pre[100005], dis[100005], a[100005],
    b[100005], L, R, ans;
long long n, m;
queue<long long> q;
vector<long long> G[100005];
long long check(long long x) {
  memset(f, 0, sizeof(f));
  f[1] = 1;
  while (1) {
    long long sm = 0;
    for (long long i = 1; i <= n; i++) vis[i] = f[i], pre[i] = 0, sm += f[i];
    if (sm == n) return 1;
    for (long long i = 1; i <= n; i++)
      if (f[i]) q.push(i), dis[i] = x;
    long long U = 0, V = 0;
    while (!q.empty()) {
      long long u = q.front();
      q.pop();
      for (auto v : G[u]) {
        if (f[v] && f[u]) continue;
        if (dis[u] <= a[v] || pre[u] == v) continue;
        if (vis[v]) {
          U = u;
          V = v;
          break;
        }
        dis[v] = dis[u] + b[v];
        vis[v] = 1;
        q.push(v);
        pre[v] = u;
      }
      if (U) break;
    }
    while (!q.empty()) q.pop();
    if (!U) return 0;
    for (; !f[U]; U = pre[U]) f[U] = 1, x += b[U];
    for (; !f[V]; V = pre[V]) f[V] = 1, x += b[V];
  }
}
signed main() {
  long long T = read();
  while (T--) {
    n = read(), m = read();
    for (long long i = 2; i <= n; i++) a[i] = read();
    for (long long i = 2; i <= n; i++) b[i] = read();
    for (long long i = 1; i <= m; i++) {
      long long u = read(), v = read();
      G[u].push_back(v);
      G[v].push_back(u);
    }
    L = 0, R = 1e14;
    ans = 0;
    while (L <= R) {
      long long mid = L + (R - L) / 2;
      if (check(mid))
        ans = mid, R = mid - 1;
      else
        L = mid + 1;
    }
    writeln(ans);
    for (long long i = 1; i <= n; i++) G[i].clear();
  }
}
