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

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

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

i = A("i")
a = B("a")
j = C("j")

i.t = j
a.x = i
j.q = a
j.v = a
assert i.t.v.x.txt == "
class A:
    def __init__(self, txt: str):
        self.t: C = None
        self.txt = txt

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

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

i = A("i")
a = B("a")
j = C("j")

i.t = j
a.x = i
j.q = a
j.v = a
assert i.t.v.x.txt == "i"