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

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

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

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

b = A("b")
d = B("d")
f = C("f")
g = D("g")
h = A("h")
m = B("m")
i = B("i")
e = C("e")
a = A("a")

b.v = a
b.t = g
b.w = f
b.r = d
d.v = e
d.o = m
d.x = g
d.z = f
f.y = h
g.v = i
h.v = b
h.t = g
h.w = f
h.r = m
m.v = e
m.z = e
m.o = d
m.x = g
i.v = f
i.z = f
i.o = d
i.x = g
e.y = h
a.v = b
a.t = g
a.w = e
a.r = i
assert h.r.x.v.v.txt == "
class A:
    def __init__(self, txt: str):
        self.v: A = None
        self.t: D = None
        self.w: C = None
        self.r: B = None
        self.txt = txt

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

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

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

b = A("b")
d = B("d")
f = C("f")
g = D("g")
h = A("h")
m = B("m")
i = B("i")
e = C("e")
a = A("a")

b.v = a
b.t = g
b.w = f
b.r = d
d.v = e
d.o = m
d.x = g
d.z = f
f.y = h
g.v = i
h.v = b
h.t = g
h.w = f
h.r = m
m.v = e
m.z = e
m.o = d
m.x = g
i.v = f
i.z = f
i.o = d
i.x = g
e.y = h
a.v = b
a.t = g
a.w = e
a.r = i
assert h.r.x.v.v.txt == "f"