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

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

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

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

d = A("d")
c = B("c")
j = C("j")
i = D("i")
h = A("h")
k = C("k")
e = B("e")
a = D("a")

d.r = j
d.s = e
d.z = i
c.p = a
c.w = j
c.z = h
c.x = k
j.v = c
i.u = d
i.r = d
i.y = j
i.q = e
h.r = j
h.s = e
h.z = i
k.v = e
e.p = i
e.w = j
e.x = j
e.z = d
a.u = h
a.y = k
a.q = e
a.r = d
assert a.q.w.v.x.v.w.txt == "
class A:
    def __init__(self, txt: str):
        self.r: C = None
        self.s: B = None
        self.z: D = None
        self.txt = txt

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

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

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

d = A("d")
c = B("c")
j = C("j")
i = D("i")
h = A("h")
k = C("k")
e = B("e")
a = D("a")

d.r = j
d.s = e
d.z = i
c.p = a
c.w = j
c.z = h
c.x = k
j.v = c
i.u = d
i.r = d
i.y = j
i.q = e
h.r = j
h.s = e
h.z = i
k.v = e
e.p = i
e.w = j
e.x = j
e.z = d
a.u = h
a.y = k
a.q = e
a.r = d
assert a.q.w.v.x.v.w.txt == "j"