func_code_string: #include<bits/stdc++.h>      #define ld long double   #define ll long long   using namespace std;   template<class T>   void read(T& x)   {    T res = 0, f = 1; char c = getchar();    while (!isdigit(c)) {     if (c ==  - )f = -1; c = getchar();    }    while (isdigit(c)) {     res = (res << 3) + (res << 1) + c -  0 ; c = getchar();    }    x = res * f;   }   const ll N = 200000 + 10;   const int mod = 1e9 + 7;      struct seg   {   #define ls(x) (x<<1)   #define rs(x) (x<<1|1)   #define mid (l+r)/2    int mn[N << 2],n,a[N],tag[N<<2];    void init(int x,int *dp)    {     n = x;     for (int i = 1; i <= n; i++)a[i] = dp[i];     build(1, 1, n);    }    void push_up(int p)    {     mn[p] = min(mn[ls(p)], mn[rs(p)]);    }    void build(int p, int l, int r)    {     if (l == r)     {      mn[p] = a[l];      return;     }     build(ls(p), l, mid);     build(rs(p), mid + 1, r);     push_up(p);    }       int query(int p, int l, int r, int nl,int nr)    {     if (l >nr || nl>r)return 1e9;     if (nl<=l&&r<=nr)     {      return mn[p];     }         return  min(query(ls(p), l, mid, nl,nr), query(rs(p), mid + 1, r, nl,nr));    }   }seg;   int n[5],dp[5][N];   int w[5][N];   vector<int>p[5][N];   int main()   {    //ios::sync_with_stdio(false);   #ifndef ONLINE_JUDGE    freopen( test.in ,  r , stdin);   #endif // ONLINE_JUDGE    for (int i = 1; i <= 4; i++)read(n[i]);    for (int i = 1; i <= 4; i++)     for (int j = 1; j <= n[i]; j++)      read(w[i][j]);    for (int i = 2; i <= 4; i++)    {     int m; read(m);     for (int j = 1; j <= n[i]; j++)p[i][j].push_back(0);     for (int j = 1; j <= m; j++)     {      int x, y; read(x), read(y);      p[i][y].push_back(x);     }     for (int j = 1; j <= n[i]; j++)p[i][j].push_back(n[i-1]+1);    }    memset(dp, 0x3f, sizeof(dp));    for (int i = 1; i <= n[1]; i++)dp[1][i] = w[1][i];       for (int i = 2; i <= 4; i++)    {     seg.init(n[i-1],dp[i-1]);     for (int j = 1; j <= n[i]; j++)sort(p[i][j].begin(), p[i][j].end());          for (int j =1; j <=n[i]; j++)     {      for (int k = 0; k + 1 < p[i][j].size(); k++)      {       dp[i][j] = min(dp[i][j], w[i][j] + seg.query(1, 1, n[i - 1], p[i][j][k] + 1, p[i][j][k + 1] - 1));      }     }         }    int ans = 1e9;    for (int i = 1; i <= n[4]; i++)ans = min(ans, dp[4][i]);    printf( %d n , ans==1e9?-1:ans);    return 0;   }   