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

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

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

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

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

j.p = f
j.v = f
j.s = m
k.y = n
k.q = i
d.p = f
d.r = f
d.q = i
g.y = d
g.q = n
g.w = f
n.y = d
n.q = c
n.w = j
c.y = d
c.q = b
c.w = j
i.y = b
i.q = k
f.p = j
f.v = j
f.s = m
m.p = j
m.q = i
m.r = f
b.y = m
b.q = c
b.w = j
assert n.y.r.s.r.s.txt == "
class A:
    def __init__(self, txt: str):
        self.p: A = None
        self.v: A = None
        self.s: C = None
        self.txt = txt

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

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

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

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

j.p = f
j.v = f
j.s = m
k.y = n
k.q = i
d.p = f
d.r = f
d.q = i
g.y = d
g.q = n
g.w = f
n.y = d
n.q = c
n.w = j
c.y = d
c.q = b
c.w = j
i.y = b
i.q = k
f.p = j
f.v = j
f.s = m
m.p = j
m.q = i
m.r = f
b.y = m
b.q = c
b.w = j
assert n.y.r.s.r.s.txt == "m"