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

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

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

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

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

d.w = f
d.q = j
g.x = c
g.r = h
j.x = h
j.r = h
j.q = g
f.u = a
f.v = d
f.y = j
f.r = i
c.u = f
c.v = e
c.y = j
c.r = i
l.u = a
l.v = d
l.y = j
l.r = i
e.w = a
e.q = j
i.x = c
i.r = h
a.u = f
a.v = e
a.y = j
a.r = i
h.x = l
h.r = i
assert h.x.y.q.x.txt == "
class A:
    def __init__(self, txt: str):
        self.w: D = None
        self.q: C = None
        self.txt = txt

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

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

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

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

d.w = f
d.q = j
g.x = c
g.r = h
j.x = h
j.r = h
j.q = g
f.u = a
f.v = d
f.y = j
f.r = i
c.u = f
c.v = e
c.y = j
c.r = i
l.u = a
l.v = d
l.y = j
l.r = i
e.w = a
e.q = j
i.x = c
i.r = h
a.u = f
a.v = e
a.y = j
a.r = i
h.x = l
h.r = i
assert h.x.y.q.x.txt == "c"