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

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

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

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

a = A("a")
d = B("d")
e = C("e")
l = D("l")
b = A("b")
m = D("m")
c = D("c")
h = C("h")
j = A("j")
g = B("g")

a.x = e
a.r = m
a.w = c
a.q = c
d.x = g
d.w = g
d.r = a
d.s = e
e.x = g
e.z = h
e.p = h
l.w = h
l.o = h
l.t = e
b.x = e
b.r = c
b.w = m
b.q = m
m.w = e
m.t = h
m.o = h
c.w = h
c.t = e
c.o = e
h.x = g
h.z = e
h.p = e
j.x = h
j.r = m
j.q = m
j.w = c
g.x = d
g.w = d
g.r = a
g.s = h
assert h.x.x.r.q.w.txt == "
class A:
    def __init__(self, txt: str):
        self.x: C = None
        self.r: D = None
        self.w: D = None
        self.q: D = None
        self.txt = txt

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

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

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

a = A("a")
d = B("d")
e = C("e")
l = D("l")
b = A("b")
m = D("m")
c = D("c")
h = C("h")
j = A("j")
g = B("g")

a.x = e
a.r = m
a.w = c
a.q = c
d.x = g
d.w = g
d.r = a
d.s = e
e.x = g
e.z = h
e.p = h
l.w = h
l.o = h
l.t = e
b.x = e
b.r = c
b.w = m
b.q = m
m.w = e
m.t = h
m.o = h
c.w = h
c.t = e
c.o = e
h.x = g
h.z = e
h.p = e
j.x = h
j.r = m
j.q = m
j.w = c
g.x = d
g.w = d
g.r = a
g.s = h
assert h.x.x.r.q.w.txt == "h"