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

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

d = A("d")
i = B("i")
g = B("g")
k = A("k")
e = B("e")
j = B("j")
c = B("c")
l = A("l")
n = A("n")
m = A("m")

d.w = m
d.u = c
i.s = e
g.s = i
k.w = d
k.u = j
e.s = g
j.s = c
c.s = e
l.w = d
l.u = j
n.w = k
n.u = i
m.w = k
m.u = e
assert c.s.s.s.s.s.s.s.txt == "
class A:
    def __init__(self, txt: str):
        self.w: A = None
        self.u: B = None
        self.txt = txt

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

d = A("d")
i = B("i")
g = B("g")
k = A("k")
e = B("e")
j = B("j")
c = B("c")
l = A("l")
n = A("n")
m = A("m")

d.w = m
d.u = c
i.s = e
g.s = i
k.w = d
k.u = j
e.s = g
j.s = c
c.s = e
l.w = d
l.u = j
n.w = k
n.u = i
m.w = k
m.u = e
assert c.s.s.s.s.s.s.s.txt == "e"