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

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

e = A("e")
b = B("b")
f = A("f")
m = A("m")
j = B("j")
l = B("l")
n = B("n")
c = A("c")
g = A("g")

e.x = l
e.w = l
b.y = l
b.r = j
f.x = n
f.w = n
m.x = j
m.w = j
j.y = l
j.r = n
l.y = j
l.r = n
n.y = b
n.r = l
c.x = l
c.w = l
g.x = j
g.w = l
assert b.r.r.r.y.r.txt == "
class A:
    def __init__(self, txt: str):
        self.x: B = None
        self.w: B = None
        self.txt = txt

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

e = A("e")
b = B("b")
f = A("f")
m = A("m")
j = B("j")
l = B("l")
n = B("n")
c = A("c")
g = A("g")

e.x = l
e.w = l
b.y = l
b.r = j
f.x = n
f.w = n
m.x = j
m.w = j
j.y = l
j.r = n
l.y = j
l.r = n
n.y = b
n.r = l
c.x = l
c.w = l
g.x = j
g.w = l
assert b.r.r.r.y.r.txt == "n"