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

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

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

h.s = a
b.z = f
b.u = n
e.z = d
e.u = h
n.s = h
d.z = e
d.u = a
f.z = e
f.u = h
a.s = h
assert n.s.s.s.s.s.txt == "
class A:
    def __init__(self, txt: str):
        self.s: A = None
        self.txt = txt

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

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

h.s = a
b.z = f
b.u = n
e.z = d
e.u = h
n.s = h
d.z = e
d.u = a
f.z = e
f.u = h
a.s = h
assert n.s.s.s.s.s.txt == "h"