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

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

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

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

a = A("a")
k = B("k")
d = C("d")
n = D("n")
i = C("i")
e = A("e")
j = D("j")
f = D("f")

a.x = i
a.z = d
k.q = d
k.z = j
d.r = j
d.p = i
d.w = e
d.x = n
n.x = a
n.z = i
n.w = j
n.p = j
i.r = j
i.p = d
i.w = e
i.x = f
e.x = d
e.z = d
j.x = e
j.z = i
j.w = n
j.p = f
f.x = a
f.z = i
f.w = j
f.p = n
assert i.r.w.x.x.txt == "
class A:
    def __init__(self, txt: str):
        self.x: C = None
        self.z: C = None
        self.txt = txt

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

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

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

a = A("a")
k = B("k")
d = C("d")
n = D("n")
i = C("i")
e = A("e")
j = D("j")
f = D("f")

a.x = i
a.z = d
k.q = d
k.z = j
d.r = j
d.p = i
d.w = e
d.x = n
n.x = a
n.z = i
n.w = j
n.p = j
i.r = j
i.p = d
i.w = e
i.x = f
e.x = d
e.z = d
j.x = e
j.z = i
j.w = n
j.p = f
f.x = a
f.z = i
f.w = j
f.p = n
assert i.r.w.x.x.txt == "i"