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

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

class C:
    def __init__(self, txt: str):
        self.x: C = None
        self.t: D = None
        self.q: A = None
        self.txt = txt

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

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

e.o = g
e.v = b
h.w = b
h.y = b
h.v = f
h.z = a
a.x = g
a.t = m
a.q = b
m.v = e
m.w = a
m.u = h
n.x = a
n.t = m
n.q = b
f.v = e
f.w = a
f.u = h
g.x = a
g.t = m
g.q = e
b.o = n
b.v = e
assert h.z.x.x.t.v.o.x.txt == "
class A:
    def __init__(self, txt: str):
        self.o: C = None
        self.v: A = None
        self.txt = txt

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

class C:
    def __init__(self, txt: str):
        self.x: C = None
        self.t: D = None
        self.q: A = None
        self.txt = txt

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

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

e.o = g
e.v = b
h.w = b
h.y = b
h.v = f
h.z = a
a.x = g
a.t = m
a.q = b
m.v = e
m.w = a
m.u = h
n.x = a
n.t = m
n.q = b
f.v = e
f.w = a
f.u = h
g.x = a
g.t = m
g.q = e
b.o = n
b.v = e
assert h.z.x.x.t.v.o.x.txt == "a"