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

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

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

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

h = A("h")
n = B("n")
j = C("j")
m = D("m")
e = C("e")
i = C("i")
f = C("f")
g = B("g")

h.o = g
h.v = m
h.x = n
n.u = h
n.q = h
n.x = g
n.v = m
j.w = m
j.r = e
m.o = n
m.u = h
e.w = m
e.r = i
i.w = m
i.r = f
f.w = m
f.r = i
g.u = h
g.q = h
g.x = n
g.v = m
assert g.x.v.o.txt == "
class A:
    def __init__(self, txt: str):
        self.o: B = None
        self.v: D = None
        self.x: B = None
        self.txt = txt

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

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

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

h = A("h")
n = B("n")
j = C("j")
m = D("m")
e = C("e")
i = C("i")
f = C("f")
g = B("g")

h.o = g
h.v = m
h.x = n
n.u = h
n.q = h
n.x = g
n.v = m
j.w = m
j.r = e
m.o = n
m.u = h
e.w = m
e.r = i
i.w = m
i.r = f
f.w = m
f.r = i
g.u = h
g.q = h
g.x = n
g.v = m
assert g.x.v.o.txt == "n"