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

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

h = A("h")
j = B("j")
c = A("c")
f = A("f")
n = B("n")
l = B("l")
a = B("a")
e = B("e")

h.u = e
j.u = c
c.u = l
f.u = n
n.u = f
l.u = f
a.u = f
e.u = c
assert c.u.u.u.txt == "
class A:
    def __init__(self, txt: str):
        self.u: B = None
        self.txt = txt

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

h = A("h")
j = B("j")
c = A("c")
f = A("f")
n = B("n")
l = B("l")
a = B("a")
e = B("e")

h.u = e
j.u = c
c.u = l
f.u = n
n.u = f
l.u = f
a.u = f
e.u = c
assert c.u.u.u.txt == "n"