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

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

a = A("a")
e = B("e")
j = B("j")
i = B("i")
d = A("d")
l = B("l")
k = B("k")

a.x = d
e.s = j
e.o = a
j.s = e
j.o = d
i.s = l
i.o = a
d.x = a
l.s = i
l.o = a
k.s = j
k.o = d
assert i.s.o.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: B = None
        self.o: A = None
        self.txt = txt

a = A("a")
e = B("e")
j = B("j")
i = B("i")
d = A("d")
l = B("l")
k = B("k")

a.x = d
e.s = j
e.o = a
j.s = e
j.o = d
i.s = l
i.o = a
d.x = a
l.s = i
l.o = a
k.s = j
k.o = d
assert i.s.o.x.x.x.txt == "d"