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

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

h = A("h")
j = B("j")
n = B("n")
k = B("k")
c = A("c")
b = A("b")

h.u = b
j.s = h
n.s = h
k.s = c
c.u = b
b.u = c
assert b.u.u.u.u.txt == "
class A:
    def __init__(self, txt: str):
        self.u: A = None
        self.txt = txt

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

h = A("h")
j = B("j")
n = B("n")
k = B("k")
c = A("c")
b = A("b")

h.u = b
j.s = h
n.s = h
k.s = c
c.u = b
b.u = c
assert b.u.u.u.u.txt == "b"