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

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

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

n.w = c
n.y = i
i.r = n
i.x = a
k.r = n
k.x = c
f.w = c
f.y = i
b.r = n
b.x = a
e.w = c
e.y = k
a.w = n
a.y = b
c.w = a
c.y = i
assert e.w.y.r.w.w.txt == "
class A:
    def __init__(self, txt: str):
        self.w: A = None
        self.y: B = None
        self.txt = txt

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

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

n.w = c
n.y = i
i.r = n
i.x = a
k.r = n
k.x = c
f.w = c
f.y = i
b.r = n
b.x = a
e.w = c
e.y = k
a.w = n
a.y = b
c.w = a
c.y = i
assert e.w.y.r.w.w.txt == "a"