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

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

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

l = A("l")
k = B("k")
e = C("e")
h = A("h")
d = C("d")

l.w = d
l.p = h
k.z = e
k.y = e
e.v = d
h.w = e
h.p = l
d.v = e
assert l.p.p.p.p.txt == "
class A:
    def __init__(self, txt: str):
        self.w: C = None
        self.p: A = None
        self.txt = txt

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

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

l = A("l")
k = B("k")
e = C("e")
h = A("h")
d = C("d")

l.w = d
l.p = h
k.z = e
k.y = e
e.v = d
h.w = e
h.p = l
d.v = e
assert l.p.p.p.p.txt == "l"