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

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

l = A("l")
d = B("d")
f = B("f")
c = A("c")
i = A("i")
b = A("b")
n = A("n")
g = A("g")

l.w = f
l.p = d
d.s = i
d.r = f
f.s = n
f.r = d
c.w = f
c.p = f
i.w = f
i.p = f
b.w = d
b.p = d
n.w = f
n.p = d
g.w = d
g.p = d
assert c.w.r.s.w.r.txt == "
class A:
    def __init__(self, txt: str):
        self.w: B = None
        self.p: B = None
        self.txt = txt

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

l = A("l")
d = B("d")
f = B("f")
c = A("c")
i = A("i")
b = A("b")
n = A("n")
g = A("g")

l.w = f
l.p = d
d.s = i
d.r = f
f.s = n
f.r = d
c.w = f
c.p = f
i.w = f
i.p = f
b.w = d
b.p = d
n.w = f
n.p = d
g.w = d
g.p = d
assert c.w.r.s.w.r.txt == "d"