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

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

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

e = A("e")
n = B("n")
m = C("m")
i = C("i")
f = C("f")

e.r = f
e.q = n
n.u = m
n.w = e
m.y = i
i.y = f
f.y = m
assert e.q.w.q.txt == "
class A:
    def __init__(self, txt: str):
        self.r: C = None
        self.q: B = None
        self.txt = txt

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

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

e = A("e")
n = B("n")
m = C("m")
i = C("i")
f = C("f")

e.r = f
e.q = n
n.u = m
n.w = e
m.y = i
i.y = f
f.y = m
assert e.q.w.q.txt == "n"