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

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

b = A("b")
g = B("g")
i = A("i")
e = A("e")
l = A("l")
n = A("n")
a = B("a")
m = B("m")
c = B("c")
j = B("j")

b.w = i
b.q = i
g.x = i
i.w = b
i.q = n
e.w = i
e.q = b
l.w = n
l.q = e
n.w = i
n.q = l
a.x = e
m.x = n
c.x = n
j.x = n
assert c.x.w.w.w.w.txt == "
class A:
    def __init__(self, txt: str):
        self.w: A = None
        self.q: A = None
        self.txt = txt

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

b = A("b")
g = B("g")
i = A("i")
e = A("e")
l = A("l")
n = A("n")
a = B("a")
m = B("m")
c = B("c")
j = B("j")

b.w = i
b.q = i
g.x = i
i.w = b
i.q = n
e.w = i
e.q = b
l.w = n
l.q = e
n.w = i
n.q = l
a.x = e
m.x = n
c.x = n
j.x = n
assert c.x.w.w.w.w.txt == "b"