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

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

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

g = A("g")
e = B("e")
k = C("k")
b = A("b")
j = C("j")
m = B("m")

g.q = m
g.x = j
e.w = m
e.q = j
k.x = b
k.r = j
k.s = m
b.q = e
b.x = k
j.x = b
j.r = k
j.s = e
m.w = e
m.q = j
assert m.q.s.w.q.x.txt == "
class A:
    def __init__(self, txt: str):
        self.q: B = None
        self.x: C = None
        self.txt = txt

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

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

g = A("g")
e = B("e")
k = C("k")
b = A("b")
j = C("j")
m = B("m")

g.q = m
g.x = j
e.w = m
e.q = j
k.x = b
k.r = j
k.s = m
b.q = e
b.x = k
j.x = b
j.r = k
j.s = e
m.w = e
m.q = j
assert m.q.s.w.q.x.txt == "b"