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

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

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

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

class E:
    def __init__(self, txt: str):
        self.r: C = None
        self.q: C = None
        self.x: B = None
        self.w: A = None
        self.txt = txt

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

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

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

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

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

class E:
    def __init__(self, txt: str):
        self.r: C = None
        self.q: C = None
        self.x: B = None
        self.w: A = None
        self.txt = txt

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

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