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

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

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

l = A("l")
a = B("a")
h = C("h")
k = A("k")

l.x = h
a.w = l
h.u = k
h.z = l
k.x = h
assert l.x.z.x.txt == "
class A:
    def __init__(self, txt: str):
        self.x: C = None
        self.txt = txt

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

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

l = A("l")
a = B("a")
h = C("h")
k = A("k")

l.x = h
a.w = l
h.u = k
h.z = l
k.x = h
assert l.x.z.x.txt == "h"