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

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

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

h = A("h")
g = B("g")
a = C("a")
m = B("m")
c = C("c")
d = C("d")
k = C("k")
i = A("i")
n = C("n")
l = C("l")

h.t = k
g.y = i
g.r = i
g.s = i
a.x = i
a.p = m
a.q = l
m.y = h
m.r = h
m.s = h
c.x = h
c.p = g
c.q = d
d.x = h
d.p = m
d.q = k
k.x = h
k.p = m
k.q = d
i.t = k
n.x = h
n.p = m
n.q = a
l.x = h
l.p = m
l.q = c
assert i.t.p.r.t.q.p.y.t.txt == "
class A:
    def __init__(self, txt: str):
        self.t: C = None
        self.txt = txt

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

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

h = A("h")
g = B("g")
a = C("a")
m = B("m")
c = C("c")
d = C("d")
k = C("k")
i = A("i")
n = C("n")
l = C("l")

h.t = k
g.y = i
g.r = i
g.s = i
a.x = i
a.p = m
a.q = l
m.y = h
m.r = h
m.s = h
c.x = h
c.p = g
c.q = d
d.x = h
d.p = m
d.q = k
k.x = h
k.p = m
k.q = d
i.t = k
n.x = h
n.p = m
n.q = a
l.x = h
l.p = m
l.q = c
assert i.t.p.r.t.q.p.y.t.txt == "k"