class A:
    def __init__(self, txt: str):
        self.q: B = None
        self.s: A = 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.x: B = None
        self.p: B = None
        self.txt = txt

b = A("b")
a = B("a")
l = C("l")
g = C("g")
c = A("c")
i = B("i")
j = B("j")

b.q = a
b.s = c
a.q = c
a.w = c
l.x = i
l.p = j
g.x = i
g.p = i
c.q = j
c.s = b
i.q = b
i.w = b
j.q = b
j.w = c
assert c.q.q.s.s.q.txt == "
class A:
    def __init__(self, txt: str):
        self.q: B = None
        self.s: A = 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.x: B = None
        self.p: B = None
        self.txt = txt

b = A("b")
a = B("a")
l = C("l")
g = C("g")
c = A("c")
i = B("i")
j = B("j")

b.q = a
b.s = c
a.q = c
a.w = c
l.x = i
l.p = j
g.x = i
g.p = i
c.q = j
c.s = b
i.q = b
i.w = b
j.q = b
j.w = c
assert c.q.q.s.s.q.txt == "a"