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

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

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

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

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

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

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

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

i.y = f
i.v = e
e.u = i
e.y = i
e.q = i
f.o = e
assert i.y.o.q.txt == "i"