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

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

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

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

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

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

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

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

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