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

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

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

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

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

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

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

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

i.r = m
e.v = i
k.q = e
k.y = e
k.o = i
m.q = e
m.y = e
m.o = i
assert e.v.r.o.txt == "i"