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

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

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

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

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

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

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

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

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

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

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