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

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

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

j = A("j")
e = B("e")
i = C("i")
h = A("h")
a = C("a")

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

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

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

j = A("j")
e = B("e")
i = C("i")
h = A("h")
a = C("a")

j.v = h
j.u = e
e.p = j
e.v = h
i.z = a
h.v = j
h.u = e
a.z = i
assert a.z.z.z.txt == "i"