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

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

m = A("m")
a = B("a")
j = A("j")
k = A("k")
f = B("f")
c = A("c")
n = B("n")
b = A("b")
i = A("i")

m.w = b
m.x = i
a.p = b
a.s = f
j.w = m
j.x = m
k.w = j
k.x = b
f.p = i
f.s = a
c.w = m
c.x = m
n.p = j
n.s = f
b.w = j
b.x = k
i.w = c
i.x = k
assert b.x.w.w.x.x.w.x.x.w.txt == "
class A:
    def __init__(self, txt: str):
        self.w: A = None
        self.x: A = None
        self.txt = txt

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

m = A("m")
a = B("a")
j = A("j")
k = A("k")
f = B("f")
c = A("c")
n = B("n")
b = A("b")
i = A("i")

m.w = b
m.x = i
a.p = b
a.s = f
j.w = m
j.x = m
k.w = j
k.x = b
f.p = i
f.s = a
c.w = m
c.x = m
n.p = j
n.s = f
b.w = j
b.x = k
i.w = c
i.x = k
assert b.x.w.w.x.x.w.x.x.w.txt == "c"