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

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

d = A("d")
c = B("c")
g = B("g")
i = B("i")
a = B("a")
l = B("l")
k = A("k")
m = B("m")

d.y = l
d.q = a
c.q = m
c.w = d
g.q = a
g.w = d
i.q = l
i.w = k
a.q = i
a.w = k
l.q = c
l.w = d
k.y = l
k.q = m
m.q = c
m.w = d
assert g.q.w.q.txt == "
class A:
    def __init__(self, txt: str):
        self.y: B = None
        self.q: B = None
        self.txt = txt

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

d = A("d")
c = B("c")
g = B("g")
i = B("i")
a = B("a")
l = B("l")
k = A("k")
m = B("m")

d.y = l
d.q = a
c.q = m
c.w = d
g.q = a
g.w = d
i.q = l
i.w = k
a.q = i
a.w = k
l.q = c
l.w = d
k.y = l
k.q = m
m.q = c
m.w = d
assert g.q.w.q.txt == "m"