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

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

c = A("c")
k = B("k")
j = A("j")
e = B("e")
d = B("d")
l = A("l")
n = B("n")
b = B("b")

c.x = l
k.s = j
j.x = l
e.s = c
d.s = j
l.x = c
n.s = c
b.s = l
assert k.s.x.x.x.txt == "
class A:
    def __init__(self, txt: str):
        self.x: A = None
        self.txt = txt

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

c = A("c")
k = B("k")
j = A("j")
e = B("e")
d = B("d")
l = A("l")
n = B("n")
b = B("b")

c.x = l
k.s = j
j.x = l
e.s = c
d.s = j
l.x = c
n.s = c
b.s = l
assert k.s.x.x.x.txt == "l"