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

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

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

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

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

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

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

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

m.r = g
m.o = g
m.s = e
h.s = e
d.p = j
d.x = h
d.t = e
g.r = m
g.o = m
g.s = d
j.s = e
e.p = j
e.x = i
e.t = d
i.s = e
assert h.s.x.s.x.s.t.txt == "d"