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

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

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

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

h.r = e
h.x = f
h.z = f
e.r = k
f.o = n
k.o = h
n.r = e
n.x = k
n.z = f
assert f.o.x.o.z.txt == "
class A:
    def __init__(self, txt: str):
        self.r: B = None
        self.x: C = None
        self.z: C = None
        self.txt = txt

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

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

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

h.r = e
h.x = f
h.z = f
e.r = k
f.o = n
k.o = h
n.r = e
n.x = k
n.z = f
assert f.o.x.o.z.txt == "f"