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

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

i = A("i")
h = B("h")
b = B("b")
g = B("g")
j = A("j")
e = B("e")
n = A("n")
k = A("k")
d = B("d")
a = A("a")

i.z = k
i.u = b
h.v = k
b.v = k
g.v = n
j.z = a
j.u = b
e.v = j
n.z = a
n.u = b
k.z = n
k.u = e
d.v = k
a.z = n
a.u = d
assert e.v.u.v.z.u.v.txt == "
class A:
    def __init__(self, txt: str):
        self.z: A = None
        self.u: B = None
        self.txt = txt

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

i = A("i")
h = B("h")
b = B("b")
g = B("g")
j = A("j")
e = B("e")
n = A("n")
k = A("k")
d = B("d")
a = A("a")

i.z = k
i.u = b
h.v = k
b.v = k
g.v = n
j.z = a
j.u = b
e.v = j
n.z = a
n.u = b
k.z = n
k.u = e
d.v = k
a.z = n
a.u = d
assert e.v.u.v.z.u.v.txt == "k"