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

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

d = A("d")
i = B("i")
c = A("c")
k = A("k")
h = A("h")
a = B("a")

d.s = c
i.u = a
c.s = d
k.s = d
h.s = k
a.u = i
assert d.s.s.s.s.s.txt == "
class A:
    def __init__(self, txt: str):
        self.s: A = None
        self.txt = txt

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

d = A("d")
i = B("i")
c = A("c")
k = A("k")
h = A("h")
a = B("a")

d.s = c
i.u = a
c.s = d
k.s = d
h.s = k
a.u = i
assert d.s.s.s.s.s.txt == "c"