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

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

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

l = A("l")
i = B("i")
b = C("b")
f = B("f")
n = B("n")
h = C("h")

l.x = b
i.z = h
b.z = h
b.v = n
f.z = b
n.z = b
h.z = b
h.v = i
assert f.z.z.z.v.z.txt == "
class A:
    def __init__(self, txt: str):
        self.x: C = None
        self.txt = txt

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

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

l = A("l")
i = B("i")
b = C("b")
f = B("f")
n = B("n")
h = C("h")

l.x = b
i.z = h
b.z = h
b.v = n
f.z = b
n.z = b
h.z = b
h.v = i
assert f.z.z.z.v.z.txt == "b"