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

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

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

f = A("f")
h = B("h")
l = C("l")
k = B("k")
n = A("n")

f.u = l
f.z = l
h.z = l
h.s = l
h.r = f
l.z = f
k.z = l
k.s = l
k.r = f
n.u = l
n.z = l
assert k.r.u.z.u.z.txt == "
class A:
    def __init__(self, txt: str):
        self.u: C = None
        self.z: C = None
        self.txt = txt

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

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

f = A("f")
h = B("h")
l = C("l")
k = B("k")
n = A("n")

f.u = l
f.z = l
h.z = l
h.s = l
h.r = f
l.z = f
k.z = l
k.s = l
k.r = f
n.u = l
n.z = l
assert k.r.u.z.u.z.txt == "f"