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

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

k = A("k")
b = B("b")
e = B("e")
i = A("i")
d = A("d")
j = B("j")

k.s = b
k.p = i
b.z = d
b.u = e
e.z = d
e.u = j
i.s = b
i.p = k
d.s = b
d.p = k
j.z = d
j.u = b
assert d.s.z.s.u.u.txt == "
class A:
    def __init__(self, txt: str):
        self.s: B = None
        self.p: A = None
        self.txt = txt

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

k = A("k")
b = B("b")
e = B("e")
i = A("i")
d = A("d")
j = B("j")

k.s = b
k.p = i
b.z = d
b.u = e
e.z = d
e.u = j
i.s = b
i.p = k
d.s = b
d.p = k
j.z = d
j.u = b
assert d.s.z.s.u.u.txt == "j"