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

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

class C:
    def __init__(self, txt: str):
        self.w: B = None
        self.x: D = None
        self.t: D = None
        self.p: D = None
        self.txt = txt

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

h = A("h")
g = B("g")
i = C("i")
f = D("f")
j = C("j")
a = D("a")
n = D("n")
b = B("b")
d = A("d")

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

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

class C:
    def __init__(self, txt: str):
        self.w: B = None
        self.x: D = None
        self.t: D = None
        self.p: D = None
        self.txt = txt

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

h = A("h")
g = B("g")
i = C("i")
f = D("f")
j = C("j")
a = D("a")
n = D("n")
b = B("b")
d = A("d")

h.o = b
h.v = a
h.q = d
h.x = n
g.o = d
g.p = b
g.v = b
g.u = a
i.w = g
i.x = a
i.t = n
i.p = n
f.o = b
f.v = h
f.r = d
j.w = b
j.x = f
j.t = a
j.p = n
a.o = g
a.v = h
a.r = h
n.o = g
n.v = d
n.r = h
b.o = d
b.p = g
b.v = g
b.u = a
d.o = g
d.v = a
d.x = a
d.q = h
assert n.v.x.r.o.txt == "b"