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

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

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

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

i.u = g
i.q = j
j.s = i
j.v = i
g.s = i
assert j.s.q.v.txt == "
class A:
    def __init__(self, txt: str):
        self.u: C = None
        self.q: B = None
        self.txt = txt

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

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

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

i.u = g
i.q = j
j.s = i
j.v = i
g.s = i
assert j.s.q.v.txt == "i"