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

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

e = A("e")
j = B("j")
g = B("g")
b = B("b")
l = B("l")
c = B("c")
a = A("a")
k = B("k")
h = A("h")

e.w = l
j.r = e
j.p = e
g.r = a
g.p = a
b.r = h
b.p = a
l.r = h
l.p = h
c.r = e
c.p = a
a.w = c
k.r = e
k.p = h
h.w = k
assert c.r.w.r.w.r.txt == "
class A:
    def __init__(self, txt: str):
        self.w: B = None
        self.txt = txt

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

e = A("e")
j = B("j")
g = B("g")
b = B("b")
l = B("l")
c = B("c")
a = A("a")
k = B("k")
h = A("h")

e.w = l
j.r = e
j.p = e
g.r = a
g.p = a
b.r = h
b.p = a
l.r = h
l.p = h
c.r = e
c.p = a
a.w = c
k.r = e
k.p = h
h.w = k
assert c.r.w.r.w.r.txt == "e"