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

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

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

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

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

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

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

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

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

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

d.v = j
d.y = h
d.p = h
d.x = f
c.s = j
c.p = j
c.w = k
j.x = i
j.t = n
i.q = k
h.v = j
h.y = f
h.p = f
h.x = d
n.q = k
g.s = j
g.p = j
g.w = k
f.v = j
f.y = d
f.p = d
f.x = d
k.s = j
k.p = j
k.w = g
assert g.s.x.q.w.txt == "g"