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

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

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

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

g = A("g")
h = B("h")
m = C("m")
f = D("f")
j = A("j")
a = B("a")

g.q = a
g.p = j
g.z = m
h.p = j
h.v = m
h.r = m
m.y = g
m.t = h
m.u = h
m.w = f
f.r = m
j.q = a
j.p = g
j.z = m
a.p = j
a.v = m
a.r = m
assert a.r.w.r.y.txt == "
class A:
    def __init__(self, txt: str):
        self.q: B = None
        self.p: A = None
        self.z: C = None
        self.txt = txt

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

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

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

g = A("g")
h = B("h")
m = C("m")
f = D("f")
j = A("j")
a = B("a")

g.q = a
g.p = j
g.z = m
h.p = j
h.v = m
h.r = m
m.y = g
m.t = h
m.u = h
m.w = f
f.r = m
j.q = a
j.p = g
j.z = m
a.p = j
a.v = m
a.r = m
assert a.r.w.r.y.txt == "g"