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

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

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

b = A("b")
g = B("g")
e = C("e")
j = C("j")
m = B("m")
d = B("d")
h = C("h")
a = C("a")

b.o = a
b.r = h
g.u = b
e.t = b
e.o = b
e.s = g
j.t = b
j.o = b
j.s = d
m.u = b
d.u = b
h.t = b
h.o = b
h.s = d
a.t = b
a.o = b
a.s = g
assert m.u.o.s.txt == "
class A:
    def __init__(self, txt: str):
        self.o: C = None
        self.r: C = None
        self.txt = txt

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

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

b = A("b")
g = B("g")
e = C("e")
j = C("j")
m = B("m")
d = B("d")
h = C("h")
a = C("a")

b.o = a
b.r = h
g.u = b
e.t = b
e.o = b
e.s = g
j.t = b
j.o = b
j.s = d
m.u = b
d.u = b
h.t = b
h.o = b
h.s = d
a.t = b
a.o = b
a.s = g
assert m.u.o.s.txt == "g"