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

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

j = A("j")
l = B("l")
g = A("g")
m = A("m")
h = B("h")
d = B("d")

j.y = h
j.s = l
l.o = h
l.v = h
g.y = h
g.s = l
m.y = h
m.s = h
h.o = l
h.v = d
d.o = h
d.v = l
assert j.y.v.v.v.o.o.txt == "
class A:
    def __init__(self, txt: str):
        self.y: B = None
        self.s: B = None
        self.txt = txt

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

j = A("j")
l = B("l")
g = A("g")
m = A("m")
h = B("h")
d = B("d")

j.y = h
j.s = l
l.o = h
l.v = h
g.y = h
g.s = l
m.y = h
m.s = h
h.o = l
h.v = d
d.o = h
d.v = l
assert j.y.v.v.v.o.o.txt == "h"