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

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

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

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

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

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

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

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

n.w = h
n.t = l
n.r = j
g.w = n
i.p = j
b.w = i
b.t = g
b.r = j
l.w = j
a.w = i
a.t = g
a.r = j
j.w = h
j.t = g
j.r = b
h.p = a
k.w = h
k.t = l
k.r = n
assert h.p.t.w.t.w.r.t.txt == "g"