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

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

n = A("n")
j = B("j")
c = B("c")
e = A("e")
f = A("f")
g = B("g")
b = B("b")
k = A("k")

n.o = g
n.s = g
j.x = b
j.y = k
c.x = j
c.y = f
e.o = j
e.s = j
f.o = g
f.s = c
g.x = c
g.y = k
b.x = j
b.y = n
k.o = c
k.s = g
assert n.o.x.x.txt == "
class A:
    def __init__(self, txt: str):
        self.o: B = None
        self.s: B = None
        self.txt = txt

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

n = A("n")
j = B("j")
c = B("c")
e = A("e")
f = A("f")
g = B("g")
b = B("b")
k = A("k")

n.o = g
n.s = g
j.x = b
j.y = k
c.x = j
c.y = f
e.o = j
e.s = j
f.o = g
f.s = c
g.x = c
g.y = k
b.x = j
b.y = n
k.o = c
k.s = g
assert n.o.x.x.txt == "j"