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

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

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

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

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

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

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

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

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

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

e.v = d
e.p = n
e.x = m
n.s = e
n.y = d
n.p = f
n.v = f
d.v = m
d.q = f
d.o = e
m.z = e
m.t = e
f.s = e
f.y = d
f.p = n
f.v = n
assert n.s.p.v.txt == "f"