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

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

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

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

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

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

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

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

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

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

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