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

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

i = A("i")
d = B("d")
f = A("f")
j = B("j")
m = B("m")
l = B("l")
n = B("n")
e = A("e")
g = B("g")
k = A("k")

i.x = m
i.s = n
d.o = e
f.x = g
f.s = d
j.o = e
m.o = e
l.o = i
n.o = k
e.x = l
e.s = g
g.o = i
k.x = g
k.s = d
assert l.o.x.o.x.o.s.txt == "
class A:
    def __init__(self, txt: str):
        self.x: B = None
        self.s: B = None
        self.txt = txt

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

i = A("i")
d = B("d")
f = A("f")
j = B("j")
m = B("m")
l = B("l")
n = B("n")
e = A("e")
g = B("g")
k = A("k")

i.x = m
i.s = n
d.o = e
f.x = g
f.s = d
j.o = e
m.o = e
l.o = i
n.o = k
e.x = l
e.s = g
g.o = i
k.x = g
k.s = d
assert l.o.x.o.x.o.s.txt == "n"