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

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

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

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

m = A("m")
n = B("n")
b = C("b")
i = D("i")
k = A("k")
g = A("g")
a = D("a")
c = D("c")
l = C("l")
j = D("j")

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

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

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

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

m = A("m")
n = B("n")
b = C("b")
i = D("i")
k = A("k")
g = A("g")
a = D("a")
c = D("c")
l = C("l")
j = D("j")

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