#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define ll long long
#define pii pair<int,int>
const int N=1e6+10;
const int mod=1e9+7;
using namespace std;
 
ll exgcd(ll a,ll b,ll &x,ll &y){ // ax+by=gcd(a,b)
    if(b==0){x=1,y=0; return a;}
    ll g=exgcd(b,a%b,y,x);
    y-=a/b*x;
    return g;
}
void solve(){
    ll n, m, k; scanf("%lld %lld %lld", &n, &m, &k);
    int sz = max(n, m) * 2 + 1;
    vector<int> a(n+1), b(m+1), c(sz, -1);
    for (int i = 1; i <= n; ++i) {
        scanf("%d", &a[i]); c[a[i]] = i;
    }
    for (int i = 1; i <= m; ++i) {
        scanf("%d", &b[i]); b[i] = c[b[i]];
    } 
    ll x, y, g = exgcd(n, m, x, y);
    exgcd(n / g, m / g, x, y);
    ll M = m / g, base = x;
    vector<ll> v(m+1);
    for (int  i = 1; i <= m; ++i) {
        if (b[i] == -1 || b[i] % g !=  i % g) {
            v[i] = -1;
        } else {
            ll  M = m / g;
            ll k1 = ((i - b[i]) / g * base %  M + M) % M;
            v[i] = k1 * n + b[i];
        }
    }
    ll lcm = 1ll * n / g * m;
    ll l = 1, r = 1e18, ans = 1;
    while (l <= r) {
        ll mid = (l + r) >> 1;
        ll cnt = mid, d = mid / lcm, e = mid % lcm;
        for (int i = 1; i <= m; ++i) {
            if (v[i] != -1) {
                cnt -= d + (e >= v[i]);
            }
        }
        if (cnt >= k) ans = mid, r = mid - 1;
        else l = mid + 1;
    }
    printf("%lld\n", ans);
}
int main(){
    int T = 1; // scanf("%d", &T);
    while(T--) solve();
    return 0;
}
/*
 
*/