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

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

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

class D:
    def __init__(self, txt: str):
        self.z: A = None
        self.q: B = None
        self.s: B = None
        self.x: B = None
        self.txt = txt

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

e.x = i
e.o = h
h.y = c
h.z = i
h.v = i
h.o = n
c.x = i
c.r = n
a.z = e
a.q = h
a.s = d
a.x = d
d.y = b
d.z = i
d.v = i
d.o = h
i.x = e
i.o = n
m.x = i
m.r = d
b.x = e
b.r = d
n.y = m
n.z = i
n.o = d
n.v = e
assert n.o.o.v.x.o.y.x.txt == "
class A:
    def __init__(self, txt: str):
        self.x: A = None
        self.o: B = None
        self.txt = txt

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

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

class D:
    def __init__(self, txt: str):
        self.z: A = None
        self.q: B = None
        self.s: B = None
        self.x: B = None
        self.txt = txt

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

e.x = i
e.o = h
h.y = c
h.z = i
h.v = i
h.o = n
c.x = i
c.r = n
a.z = e
a.q = h
a.s = d
a.x = d
d.y = b
d.z = i
d.v = i
d.o = h
i.x = e
i.o = n
m.x = i
m.r = d
b.x = e
b.r = d
n.y = m
n.z = i
n.o = d
n.v = e
assert n.o.o.v.x.o.y.x.txt == "i"