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

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

e = A("e")
k = B("k")
l = B("l")
a = A("a")
d = A("d")
f = A("f")
b = B("b")

e.s = b
k.p = b
k.w = f
l.p = b
l.w = d
a.s = l
d.s = b
f.s = l
b.p = l
b.w = f
assert f.s.w.s.w.s.p.txt == "
class A:
    def __init__(self, txt: str):
        self.s: B = None
        self.txt = txt

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

e = A("e")
k = B("k")
l = B("l")
a = A("a")
d = A("d")
f = A("f")
b = B("b")

e.s = b
k.p = b
k.w = f
l.p = b
l.w = d
a.s = l
d.s = b
f.s = l
b.p = l
b.w = f
assert f.s.w.s.w.s.p.txt == "b"