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

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

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

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

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

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

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

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

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

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

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