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

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

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

class D:
    def __init__(self, txt: str):
        self.v: A = None
        self.txt = txt

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

n.p = c
n.w = h
n.o = j
n.y = g
j.q = b
j.t = e
f.p = c
f.z = j
i.v = h
d.p = c
d.w = n
d.o = j
d.y = j
h.p = c
h.w = d
h.o = j
h.y = j
c.p = f
c.z = g
e.v = n
g.q = b
g.t = e
b.v = d
assert j.t.v.w.w.p.z.q.v.txt == "
class A:
    def __init__(self, txt: str):
        self.p: C = None
        self.w: A = None
        self.o: B = None
        self.y: B = None
        self.txt = txt

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

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

class D:
    def __init__(self, txt: str):
        self.v: A = None
        self.txt = txt

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

n.p = c
n.w = h
n.o = j
n.y = g
j.q = b
j.t = e
f.p = c
f.z = j
i.v = h
d.p = c
d.w = n
d.o = j
d.y = j
h.p = c
h.w = d
h.o = j
h.y = j
c.p = f
c.z = g
e.v = n
g.q = b
g.t = e
b.v = d
assert j.t.v.w.w.p.z.q.v.txt == "d"