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

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

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

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

e = A("e")
c = B("c")
d = C("d")
m = D("m")
f = D("f")
k = B("k")
n = A("n")

e.x = n
e.v = n
e.q = d
e.z = c
c.p = d
d.o = e
d.p = e
d.x = c
m.q = d
f.q = d
k.p = d
n.x = e
n.v = e
n.q = d
n.z = c
assert f.q.p.q.o.txt == "
class A:
    def __init__(self, txt: str):
        self.x: A = None
        self.q: C = None
        self.v: A = None
        self.z: B = None
        self.txt = txt

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

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

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

e = A("e")
c = B("c")
d = C("d")
m = D("m")
f = D("f")
k = B("k")
n = A("n")

e.x = n
e.v = n
e.q = d
e.z = c
c.p = d
d.o = e
d.p = e
d.x = c
m.q = d
f.q = d
k.p = d
n.x = e
n.v = e
n.q = d
n.z = c
assert f.q.p.q.o.txt == "e"