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

class B:
    def __init__(self, txt: str):
        self.w: C = None
        self.u: A = None
        self.txt = txt

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

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

class E:
    def __init__(self, txt: str):
        self.v: C = None
        self.txt = txt

h = A("h")
e = B("e")
l = C("l")
m = D("m")
g = E("g")

h.o = e
h.v = e
h.x = e
h.p = m
e.w = l
e.u = h
l.r = m
m.x = e
m.u = l
m.v = l
g.v = l
assert l.r.v.r.txt == "
class A:
    def __init__(self, txt: str):
        self.o: B = None
        self.v: B = None
        self.x: B = None
        self.p: D = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.w: C = None
        self.u: A = None
        self.txt = txt

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

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

class E:
    def __init__(self, txt: str):
        self.v: C = None
        self.txt = txt

h = A("h")
e = B("e")
l = C("l")
m = D("m")
g = E("g")

h.o = e
h.v = e
h.x = e
h.p = m
e.w = l
e.u = h
l.r = m
m.x = e
m.u = l
m.v = l
g.v = l
assert l.r.v.r.txt == "m"