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

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

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

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

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

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

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

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

j.p = g
j.s = d
b.y = i
b.t = i
g.x = e
g.t = i
g.w = j
i.x = g
i.t = g
i.w = j
l.p = e
l.s = h
h.y = g
h.t = i
e.x = g
e.t = g
e.w = j
d.y = i
d.t = i
m.p = g
m.s = d
assert g.t.w.p.t.w.p.t.x.t.txt == "i"