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

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

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

n = A("n")
a = B("a")
k = C("k")
e = A("e")
g = B("g")
h = B("h")
l = C("l")
d = A("d")
j = C("j")
b = A("b")

n.t = g
n.p = d
a.q = h
a.p = h
a.r = e
k.u = j
k.r = n
k.t = b
e.t = a
e.p = b
g.q = h
g.p = a
g.r = b
h.q = a
h.p = a
h.r = e
l.u = k
l.r = b
l.t = n
d.t = g
d.p = e
j.u = l
j.r = d
j.t = d
b.t = g
b.p = e
assert n.t.q.r.t.q.p.p.p.q.q.txt == "
class A:
    def __init__(self, txt: str):
        self.t: B = None
        self.p: A = None
        self.txt = txt

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

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

n = A("n")
a = B("a")
k = C("k")
e = A("e")
g = B("g")
h = B("h")
l = C("l")
d = A("d")
j = C("j")
b = A("b")

n.t = g
n.p = d
a.q = h
a.p = h
a.r = e
k.u = j
k.r = n
k.t = b
e.t = a
e.p = b
g.q = h
g.p = a
g.r = b
h.q = a
h.p = a
h.r = e
l.u = k
l.r = b
l.t = n
d.t = g
d.p = e
j.u = l
j.r = d
j.t = d
b.t = g
b.p = e
assert n.t.q.r.t.q.p.p.p.q.q.txt == "a"