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

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

e = A("e")
i = B("i")
m = B("m")
f = A("f")
a = A("a")
n = A("n")
d = B("d")
c = A("c")

e.t = f
e.w = i
i.u = c
m.u = f
f.t = a
f.w = i
a.t = f
a.w = d
n.t = a
n.w = i
d.u = e
c.t = a
c.w = d
assert n.w.u.w.u.w.u.w.txt == "
class A:
    def __init__(self, txt: str):
        self.t: A = None
        self.w: B = None
        self.txt = txt

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

e = A("e")
i = B("i")
m = B("m")
f = A("f")
a = A("a")
n = A("n")
d = B("d")
c = A("c")

e.t = f
e.w = i
i.u = c
m.u = f
f.t = a
f.w = i
a.t = f
a.w = d
n.t = a
n.w = i
d.u = e
c.t = a
c.w = d
assert n.w.u.w.u.w.u.w.txt == "d"