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

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

f = A("f")
h = B("h")
m = B("m")
i = A("i")
n = B("n")
b = A("b")

f.s = h
h.u = n
m.u = h
i.s = n
n.u = m
b.s = m
assert n.u.u.u.u.txt == "
class A:
    def __init__(self, txt: str):
        self.s: B = None
        self.txt = txt

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

f = A("f")
h = B("h")
m = B("m")
i = A("i")
n = B("n")
b = A("b")

f.s = h
h.u = n
m.u = h
i.s = n
n.u = m
b.s = m
assert n.u.u.u.u.txt == "m"