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

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

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

a = A("a")
j = B("j")
c = C("c")
g = B("g")

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

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

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

a = A("a")
j = B("j")
c = C("c")
g = B("g")

a.x = c
a.q = c
j.t = c
j.v = c
c.x = a
g.t = c
g.v = c
assert c.x.x.x.txt == "a"