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

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

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

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

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

d.q = e
g.z = d
g.x = d
g.r = c
b.w = j
b.o = m
b.x = h
b.u = k
m.v = d
m.w = b
h.z = d
h.x = d
h.r = c
k.v = d
k.w = e
c.z = d
c.x = d
c.r = j
j.z = d
j.x = d
j.r = c
e.w = h
e.o = k
e.u = k
e.x = g
assert d.q.x.r.x.q.x.txt == "
class A:
    def __init__(self, txt: str):
        self.q: C = None
        self.txt = txt

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

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

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

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

d.q = e
g.z = d
g.x = d
g.r = c
b.w = j
b.o = m
b.x = h
b.u = k
m.v = d
m.w = b
h.z = d
h.x = d
h.r = c
k.v = d
k.w = e
c.z = d
c.x = d
c.r = j
j.z = d
j.x = d
j.r = c
e.w = h
e.o = k
e.u = k
e.x = g
assert d.q.x.r.x.q.x.txt == "g"