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

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

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

m = A("m")
g = B("g")
c = C("c")
h = A("h")
n = B("n")
j = C("j")
i = A("i")

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

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

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

m = A("m")
g = B("g")
c = C("c")
h = A("h")
n = B("n")
j = C("j")
i = A("i")

m.y = j
m.w = j
m.s = n
g.p = n
g.x = n
g.t = i
c.y = i
c.t = i
c.p = j
h.y = j
h.w = j
h.s = n
n.p = g
n.x = g
n.t = h
j.y = h
j.t = h
j.p = c
i.y = c
i.w = j
i.s = g
assert j.t.s.t.txt == "h"