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

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

i = A("i")
n = B("n")
k = A("k")
c = A("c")
d = B("d")

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

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

i = A("i")
n = B("n")
k = A("k")
c = A("c")
d = B("d")

i.u = n
n.x = k
k.u = n
c.u = n
d.x = c
assert i.u.x.u.x.u.txt == "n"