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

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

j = A("j")
i = B("i")
b = B("b")
g = A("g")
c = B("c")
n = B("n")
d = B("d")
h = B("h")
e = B("e")
l = B("l")

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

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

j = A("j")
i = B("i")
b = B("b")
g = A("g")
c = B("c")
n = B("n")
d = B("d")
h = B("h")
e = B("e")
l = B("l")

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