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

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

i = A("i")
f = B("f")
d = B("d")
g = B("g")
e = A("e")
c = A("c")
j = A("j")
l = B("l")
k = A("k")
h = A("h")

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

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

i = A("i")
f = B("f")
d = B("d")
g = B("g")
e = A("e")
c = A("c")
j = A("j")
l = B("l")
k = A("k")
h = A("h")

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