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

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

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

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

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

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

n.o = d
d.u = n
d.s = n
e.u = g
e.s = g
g.o = b
c.u = n
c.s = n
b.u = n
b.s = n
f.u = g
f.s = n
assert d.u.o.s.o.u.txt == "n"