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

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

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

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

a = A("a")
m = B("m")
i = C("i")
h = D("h")
c = D("c")

a.y = m
a.u = m
a.p = m
a.o = m
m.z = c
m.v = h
m.r = a
i.r = h
i.x = h
h.z = c
h.x = a
h.w = a
h.t = a
c.z = h
c.x = a
c.w = a
c.t = a
assert a.o.r.p.txt == "
class A:
    def __init__(self, txt: str):
        self.y: B = None
        self.u: B = None
        self.p: B = None
        self.o: B = None
        self.txt = txt

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

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

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

a = A("a")
m = B("m")
i = C("i")
h = D("h")
c = D("c")

a.y = m
a.u = m
a.p = m
a.o = m
m.z = c
m.v = h
m.r = a
i.r = h
i.x = h
h.z = c
h.x = a
h.w = a
h.t = a
c.z = h
c.x = a
c.w = a
c.t = a
assert a.o.r.p.txt == "m"