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

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

n = A("n")
h = B("h")
a = B("a")
d = B("d")
i = B("i")
l = B("l")
c = A("c")
j = B("j")
b = B("b")

n.s = c
n.o = c
h.v = n
a.v = n
d.v = c
i.v = n
l.v = n
c.s = n
c.o = n
j.v = n
b.v = c
assert j.v.o.o.txt == "
class A:
    def __init__(self, txt: str):
        self.s: A = None
        self.o: A = None
        self.txt = txt

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

n = A("n")
h = B("h")
a = B("a")
d = B("d")
i = B("i")
l = B("l")
c = A("c")
j = B("j")
b = B("b")

n.s = c
n.o = c
h.v = n
a.v = n
d.v = c
i.v = n
l.v = n
c.s = n
c.o = n
j.v = n
b.v = c
assert j.v.o.o.txt == "n"