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

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

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

f = A("f")
i = B("i")
k = C("k")
c = B("c")
l = C("l")
h = B("h")

f.w = k
f.y = c
i.z = f
i.u = f
i.r = l
k.x = h
k.r = c
c.z = f
c.u = f
c.r = k
l.x = h
l.r = i
h.z = f
h.u = f
h.r = l
assert i.z.y.u.w.r.u.txt == "
class A:
    def __init__(self, txt: str):
        self.w: C = None
        self.y: B = None
        self.txt = txt

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

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

f = A("f")
i = B("i")
k = C("k")
c = B("c")
l = C("l")
h = B("h")

f.w = k
f.y = c
i.z = f
i.u = f
i.r = l
k.x = h
k.r = c
c.z = f
c.u = f
c.r = k
l.x = h
l.r = i
h.z = f
h.u = f
h.r = l
assert i.z.y.u.w.r.u.txt == "f"