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

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

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

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

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

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

n.u = a
k.t = a
d.u = k
a.t = k
assert d.u.t.t.txt == "k"