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

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

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

f = A("f")
d = B("d")
e = C("e")
i = A("i")
c = B("c")
m = C("m")

f.q = i
d.q = c
e.u = c
i.q = f
c.q = d
m.u = c
assert d.q.q.q.q.q.txt == "
class A:
    def __init__(self, txt: str):
        self.q: A = None
        self.txt = txt

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

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

f = A("f")
d = B("d")
e = C("e")
i = A("i")
c = B("c")
m = C("m")

f.q = i
d.q = c
e.u = c
i.q = f
c.q = d
m.u = c
assert d.q.q.q.q.q.txt == "c"