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

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

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

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

d = A("d")
e = B("e")
m = C("m")
h = D("h")

d.x = e
d.p = e
e.v = d
e.u = d
e.o = m
e.q = h
m.o = h
m.x = e
m.y = d
m.p = d
h.r = m
h.v = d
assert e.o.y.x.txt == "
class A:
    def __init__(self, txt: str):
        self.x: B = None
        self.p: B = None
        self.txt = txt

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

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

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

d = A("d")
e = B("e")
m = C("m")
h = D("h")

d.x = e
d.p = e
e.v = d
e.u = d
e.o = m
e.q = h
m.o = h
m.x = e
m.y = d
m.p = d
h.r = m
h.v = d
assert e.o.y.x.txt == "e"