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

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

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

g = A("g")
b = B("b")
j = C("j")
n = C("n")

g.s = b
b.q = g
b.w = g
j.t = g
j.u = n
n.t = g
n.u = j
assert j.t.s.q.s.txt == "
class A:
    def __init__(self, txt: str):
        self.s: B = None
        self.txt = txt

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

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

g = A("g")
b = B("b")
j = C("j")
n = C("n")

g.s = b
b.q = g
b.w = g
j.t = g
j.u = n
n.t = g
n.u = j
assert j.t.s.q.s.txt == "b"