class A:
    def __init__(self, txt: str):
        self.x: D = None
        self.v: C = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.u: E = None
        self.v: A = None
        self.txt = txt

class C:
    def __init__(self, txt: str):
        self.u: E = None
        self.txt = txt

class D:
    def __init__(self, txt: str):
        self.x: C = None
        self.p: C = None
        self.y: A = None
        self.txt = txt

class E:
    def __init__(self, txt: str):
        self.r: C = None
        self.u: B = None
        self.q: D = None
        self.p: D = None
        self.txt = txt

d = A("d")
h = B("h")
k = C("k")
j = D("j")
b = E("b")
g = C("g")
n = D("n")

d.x = j
d.v = k
h.u = b
h.v = d
k.u = b
j.x = g
j.p = k
j.y = d
b.r = g
b.u = h
b.q = n
b.p = j
g.u = b
n.x = g
n.p = k
n.y = d
assert h.u.p.y.v.txt == "
class A:
    def __init__(self, txt: str):
        self.x: D = None
        self.v: C = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.u: E = None
        self.v: A = None
        self.txt = txt

class C:
    def __init__(self, txt: str):
        self.u: E = None
        self.txt = txt

class D:
    def __init__(self, txt: str):
        self.x: C = None
        self.p: C = None
        self.y: A = None
        self.txt = txt

class E:
    def __init__(self, txt: str):
        self.r: C = None
        self.u: B = None
        self.q: D = None
        self.p: D = None
        self.txt = txt

d = A("d")
h = B("h")
k = C("k")
j = D("j")
b = E("b")
g = C("g")
n = D("n")

d.x = j
d.v = k
h.u = b
h.v = d
k.u = b
j.x = g
j.p = k
j.y = d
b.r = g
b.u = h
b.q = n
b.p = j
g.u = b
n.x = g
n.p = k
n.y = d
assert h.u.p.y.v.txt == "k"