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

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

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

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

e = A("e")
i = B("i")
g = C("g")
h = D("h")
b = C("b")
j = D("j")
d = D("d")

e.p = i
e.x = i
i.r = j
i.x = g
g.y = i
g.o = h
h.p = e
h.z = e
b.y = i
b.o = d
j.p = e
j.z = e
d.p = e
d.z = e
assert g.y.x.o.p.p.r.z.txt == "
class A:
    def __init__(self, txt: str):
        self.p: B = None
        self.x: B = None
        self.txt = txt

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

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

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

e = A("e")
i = B("i")
g = C("g")
h = D("h")
b = C("b")
j = D("j")
d = D("d")

e.p = i
e.x = i
i.r = j
i.x = g
g.y = i
g.o = h
h.p = e
h.z = e
b.y = i
b.o = d
j.p = e
j.z = e
d.p = e
d.z = e
assert g.y.x.o.p.p.r.z.txt == "e"