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

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

class C:
    def __init__(self, txt: str):
        self.t: C = None
        self.txt = txt

d = A("d")
m = B("m")
h = C("h")
g = A("g")
a = B("a")
n = B("n")
e = C("e")
c = C("c")

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

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

class C:
    def __init__(self, txt: str):
        self.t: C = None
        self.txt = txt

d = A("d")
m = B("m")
h = C("h")
g = A("g")
a = B("a")
n = B("n")
e = C("e")
c = C("c")

d.s = h
d.o = h
d.r = g
m.o = g
h.t = e
g.s = c
g.o = h
g.r = d
a.o = d
n.o = g
e.t = h
c.t = h
assert a.o.s.t.t.txt == "h"