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

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

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

n = A("n")
c = B("c")
a = C("a")
i = B("i")
f = A("f")

n.o = a
n.r = i
c.w = a
c.o = f
a.y = i
a.t = f
a.z = n
i.w = a
i.o = n
f.o = a
f.r = c
assert f.o.t.o.t.o.txt == "
class A:
    def __init__(self, txt: str):
        self.o: C = None
        self.r: B = None
        self.txt = txt

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

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

n = A("n")
c = B("c")
a = C("a")
i = B("i")
f = A("f")

n.o = a
n.r = i
c.w = a
c.o = f
a.y = i
a.t = f
a.z = n
i.w = a
i.o = n
f.o = a
f.r = c
assert f.o.t.o.t.o.txt == "a"