#include <bits/stdc++.h>
using namespace std;
namespace jyy {
const int mod = 998244353, N = 200010;
const double eps = 1e-8;
inline int read() {
  static int x = 0, f = 1;
  x = 0, f = 1;
  static char ch = getchar();
  while (ch < '0' || ch > '9') {
    (ch == '-') ? f *= -1 : f;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') x = x * 10 + int(ch - 48), ch = getchar();
  return x * f;
}
inline void fw(int x) {
  if (x < 0) putchar('-'), x = -x;
  x >= 10 ? fw(x / 10), 1 : 0;
  putchar(char(x % 10 + 48));
}
int qmo(int x) { return x + ((x >> 31) & mod); }
int ksm(int x, int y) {
  int tmp = 1;
  for (; y; y >>= 1, x = 1ll * x * x % mod)
    if (y & 1) tmp = 1ll * tmp * x % mod;
  return tmp;
}
int inv(int x) { return ksm(x, mod - 2); }
int tot, head[N], fa[N];
struct edge {
  int to, next;
} dat[N * 2];
void add_edge(int x, int y) { dat[++tot] = (edge){y, head[x]}, head[x] = tot; }
int find(int x) { return fa[x] ? fa[x] = find(fa[x]) : x; }
int merge(int x, int y) {
  return find(x) != find(y) ? fa[find(x)] = find(y), 0 : 1;
}
int low(int x) { return x & -x; }
int ifac[N], fac[N];
void init(int x) {
  fac[0] = ifac[0] = 1;
  for (int i = 1; i <= x; i++) fac[i] = 1ll * fac[i - 1] * i % mod;
  ifac[x] = inv(fac[x]);
  for (int i = x - 1; i >= 1; i--) ifac[i] = 1ll * ifac[i + 1] * (i + 1) % mod;
}
int C(int x, int y) {
  return (x < y || y < 0 || x < 0)
             ? 0
             : 1ll * fac[x] * ifac[y] % mod * ifac[x - y] % mod;
}
}  // namespace jyy
using namespace jyy;
long long dis[N];
int in[N], v[N], n, last[N], a[N], b[N], m;
queue<int> q;
bool check(long long now) {
  for (int i = 1; i <= n; i++) in[i] = 0;
  in[1] = 1;
  while (1) {
    while (q.size()) q.pop();
    for (int i = 1; i <= n; i++) v[i] = in[i], dis[i] = 0, last[i] = 0;
    for (int i = 1; i <= n; i++)
      if (in[i]) q.push(i), dis[i] = now;
    int t1 = 0, t2 = 0;
    while (!q.empty()) {
      int x = q.front();
      q.pop();
      for (int i = head[x]; i; i = dat[i].next) {
        int t = dat[i].to;
        if (last[x] == t || (in[x] && in[t])) continue;
        if (v[t]) {
          t1 = x, t2 = t;
          break;
        }
        if ((long long)a[t] >= dis[x]) continue;
        v[t] = 1, dis[t] = dis[x] + b[t], last[t] = x, q.push(t);
      }
      if (t1) break;
    }
    if (!t1) return 0;
    for (; !in[t1]; t1 = last[t1]) now += b[t1], in[t1] = 1;
    for (; !in[t2]; t2 = last[t2]) now += b[t2], in[t2] = 1;
    int res = 1;
    for (int i = 1; i <= n; i++) res &= in[i];
    if (res) return 1;
  }
  return 0;
}
void solve() {
  n = read(), m = read(), tot = 0;
  for (int i = 1; i <= n; i++) head[i] = 0;
  for (int i = 2; i <= n; i++) a[i] = read();
  for (int i = 2; i <= n; i++) b[i] = read();
  for (int i = 1, x, y; i <= m; i++)
    x = read(), y = read(), add_edge(x, y), add_edge(y, x);
  int l = 0, r = (int)1e9 + 1, ans = 0;
  while (l <= r) {
    int mid = (l + r) / 2;
    if (check(mid))
      ans = mid, r = mid - 1;
    else
      l = mid + 1;
  }
  fw(ans), puts("");
}
int T;
int main() {
  cin >> T;
  while (T--) solve();
}
