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

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

j = A("j")
k = B("k")
n = B("n")
d = B("d")

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

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

j = A("j")
k = B("k")
n = B("n")
d = B("d")

j.s = k
k.u = j
n.u = j
d.u = j
assert n.u.s.u.s.txt == "k"