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

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

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

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

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

c.u = n
c.w = h
c.p = d
e.r = n
e.t = a
m.v = c
a.r = e
d.u = e
d.w = n
d.p = c
n.r = e
n.t = a
h.r = n
h.t = a
assert m.v.w.t.r.t.r.txt == "
class A:
    def __init__(self, txt: str):
        self.u: B = None
        self.w: B = None
        self.p: A = None
        self.txt = txt

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

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

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

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

c.u = n
c.w = h
c.p = d
e.r = n
e.t = a
m.v = c
a.r = e
d.u = e
d.w = n
d.p = c
n.r = e
n.t = a
h.r = n
h.t = a
assert m.v.w.t.r.t.r.txt == "e"