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

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

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

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

a = A("a")
c = B("c")
g = C("g")
d = D("d")
i = B("i")
h = A("h")
f = C("f")
n = D("n")
l = B("l")
e = A("e")

a.r = d
a.x = d
a.v = h
c.p = i
c.y = l
c.w = l
g.z = f
d.p = h
i.p = l
i.y = l
i.w = c
h.r = d
h.v = a
h.x = n
f.z = g
n.p = h
l.p = i
l.w = i
l.y = c
e.r = d
e.v = h
e.x = n
assert a.v.r.p.r.p.v.x.p.v.v.txt == "
class A:
    def __init__(self, txt: str):
        self.r: D = None
        self.v: A = None
        self.x: D = None
        self.txt = txt

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

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

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

a = A("a")
c = B("c")
g = C("g")
d = D("d")
i = B("i")
h = A("h")
f = C("f")
n = D("n")
l = B("l")
e = A("e")

a.r = d
a.x = d
a.v = h
c.p = i
c.y = l
c.w = l
g.z = f
d.p = h
i.p = l
i.y = l
i.w = c
h.r = d
h.v = a
h.x = n
f.z = g
n.p = h
l.p = i
l.w = i
l.y = c
e.r = d
e.v = h
e.x = n
assert a.v.r.p.r.p.v.x.p.v.v.txt == "h"