import java.lang.Math.sqrt
val Int.absoluteValue: Int
    get() = if (this < 0) -this else this
val Int.sign: Int
    get() = when {
        this > 0 -> 1
        this == 0 -> 0
        this < 0 -> -1
        else -> TODO()
    }
fun <T: Comparable<T>> minOf(a: T, b: T): T {
    return if (a < b) a else b
}
inline fun <T> T.also(func: (T) -> Unit): T {
    func(this)
    return this
}
inline fun <T> T.run(func: T.() -> Unit): T {
    func(this)
    return this
}
fun main(args: Array<String>) {
    val n = readLine()!!.trim().toInt()
    val pointsA = Array(n){
        val (x, y) = readLine()!!.trim().split(' ').map(String::toInt)
        Point(x, y)
    }.toMutableList().run {
        add(0, Point(0, 0))
        add(Point(1000, 0))
    }
    val m = readLine()!!.trim().toInt()
    val pointsB = Array(m){
        val (x, y) = readLine()!!.trim().split(' ').map(String::toInt)
        Point(x, y)
    }.toMutableList().run{
        add(0, Point(0, 1000))
        add(Point(1000, 1000))
    }
    val edgesA = pointsA.indices.drop(1).map{Edge(pointsA[it], pointsA[it - 1])}
    val edgesB = pointsB.indices.drop(1).map{Edge(pointsB[it], pointsB[it - 1])}
    val minA = pointsA.flatMap{p -> edgesB.map{it.distance(p)}}.min()
    val minB = pointsB.flatMap { p -> edgesA.map { it.distance(p) } }.min()
    val minC = pointsA.first().distance(pointsB.first())
    println("%.10f".format(
            listOfNotNull(minA, minB, minC).min()!!
    )
    )
}

data class Point(val x: Int, val y: Int) {
    fun distance(that: Point): Double = (this - that).length
}
operator fun Point.minus(that: Point): Vector {
    return Vector(x - that.x, y - that.y)
}
data class Vector(val dx: Int, val dy: Int) {
    val length: Double
        get() = sqrt((dx * dx + dy * dy).toDouble())
    fun dot(that: Vector): Int = dx * that.dx + dy * that.dy
    fun cross(that: Vector): Int = dx * that.dy - dy * that.dx
}
data class Edge(val endA: Point, val endB: Point) {
    fun distance(point: Point): Double {
        return if (vec.dot(point - endB).sign * vec.dot(point - endA).sign <= 0) (a * point.x + b * point.y + c).absoluteValue / sqrt((a * a + b * b).toDouble())
        else minOf(endA.distance(point), endB.distance(point))
    }
    fun distance(that: Edge): Double {
        return listOf(distance(that.endA), distance(that.endB), that.distance(endA), that.distance(endB)).min()!!
    }
    private val vec: Vector = endA - endB
    private val a: Int = vec.dy
    private val b: Int = -vec.dx
    private val c: Int = -endB.y * b - endB.x * a
}

