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

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

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

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

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

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

c.w = f
f.s = k
f.x = l
g.s = l
g.x = k
k.w = i
m.w = g
a.s = k
a.x = c
i.s = m
i.x = c
d.w = g
h.w = f
l.w = i
assert c.w.s.w.txt == "i"