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

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

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

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

h.s = j
h.o = j
a.t = d
a.w = h
e.s = g
e.t = j
j.t = d
j.w = g
c.s = g
c.t = a
g.s = a
g.o = a
i.s = g
i.t = j
d.s = g
d.t = j
assert i.s.s.t.t.w.o.w.s.txt == "
class A:
    def __init__(self, txt: str):
        self.s: B = None
        self.o: B = None
        self.txt = txt

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

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

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

h.s = j
h.o = j
a.t = d
a.w = h
e.s = g
e.t = j
j.t = d
j.w = g
c.s = g
c.t = a
g.s = a
g.o = a
i.s = g
i.t = j
d.s = g
d.t = j
assert i.s.s.t.t.w.o.w.s.txt == "j"