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

class B:
    def __init__(self, txt: str):
        self.p: D = None
        self.x: D = None
        self.r: D = None
        self.txt = txt

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

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

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

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

class B:
    def __init__(self, txt: str):
        self.p: D = None
        self.x: D = None
        self.r: D = None
        self.txt = txt

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

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

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

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