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

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

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

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

e = A("e")
i = B("i")
g = C("g")
n = D("n")
b = A("b")

e.y = n
e.p = n
e.z = i
i.o = b
i.x = b
g.p = n
g.t = n
g.o = n
n.y = e
b.y = n
b.p = n
b.z = i
assert e.z.x.z.o.y.txt == "
class A:
    def __init__(self, txt: str):
        self.y: D = None
        self.z: B = None
        self.p: D = None
        self.txt = txt

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

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

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

e = A("e")
i = B("i")
g = C("g")
n = D("n")
b = A("b")

e.y = n
e.p = n
e.z = i
i.o = b
i.x = b
g.p = n
g.t = n
g.o = n
n.y = e
b.y = n
b.p = n
b.z = i
assert e.z.x.z.o.y.txt == "n"