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

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

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

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

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

d.p = c
d.q = c
d.x = h
e.r = j
e.v = i
e.z = h
j.z = i
i.v = e
i.q = e
i.x = j
i.z = j
h.r = j
h.v = i
h.z = e
c.p = d
c.q = d
c.x = h
n.z = i
assert d.p.x.z.v.q.v.z.txt == "
class A:
    def __init__(self, txt: str):
        self.p: A = None
        self.q: A = None
        self.x: B = None
        self.txt = txt

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

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

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

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

d.p = c
d.q = c
d.x = h
e.r = j
e.v = i
e.z = h
j.z = i
i.v = e
i.q = e
i.x = j
i.z = j
h.r = j
h.v = i
h.z = e
c.p = d
c.q = d
c.x = h
n.z = i
assert d.p.x.z.v.q.v.z.txt == "j"