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

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

i = A("i")
n = B("n")
a = A("a")
j = A("j")
h = B("h")
c = B("c")
e = A("e")
b = A("b")

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

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

i = A("i")
n = B("n")
a = A("a")
j = A("j")
h = B("h")
c = B("c")
e = A("e")
b = A("b")

i.v = j
n.z = c
n.u = i
a.v = j
j.v = e
h.z = n
h.u = b
c.z = n
c.u = i
e.v = j
b.v = j
assert b.v.v.v.v.v.v.txt == "e"