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

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

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

f = A("f")
m = B("m")
i = C("i")
k = A("k")

f.q = i
f.o = i
f.y = m
m.v = f
m.o = i
i.t = m
k.q = i
k.o = i
k.y = m
assert i.t.v.y.txt == "
class A:
    def __init__(self, txt: str):
        self.q: C = None
        self.y: B = None
        self.o: C = None
        self.txt = txt

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

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

f = A("f")
m = B("m")
i = C("i")
k = A("k")

f.q = i
f.o = i
f.y = m
m.v = f
m.o = i
i.t = m
k.q = i
k.o = i
k.y = m
assert i.t.v.y.txt == "m"