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

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

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

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

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

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

h.y = i
h.w = n
f.w = n
f.t = n
i.y = e
i.w = n
e.y = d
e.w = n
d.y = a
d.w = n
a.y = d
a.w = n
n.w = f
n.t = f
assert a.y.w.w.t.txt == "n"