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

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

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

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

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

d.r = b
d.z = m
g.x = m
c.q = d
c.z = g
c.t = k
c.o = h
h.z = d
h.w = m
h.r = m
h.y = j
k.z = j
k.w = g
k.r = g
k.y = d
b.q = d
b.z = g
b.t = i
b.o = h
j.r = c
j.z = g
m.x = g
i.z = d
i.w = m
i.y = j
i.r = g
l.z = d
l.w = g
l.y = j
l.r = m
assert c.t.z.r.t.w.txt == "
class A:
    def __init__(self, txt: str):
        self.r: C = None
        self.z: B = None
        self.txt = txt

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

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

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

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

d.r = b
d.z = m
g.x = m
c.q = d
c.z = g
c.t = k
c.o = h
h.z = d
h.w = m
h.r = m
h.y = j
k.z = j
k.w = g
k.r = g
k.y = d
b.q = d
b.z = g
b.t = i
b.o = h
j.r = c
j.z = g
m.x = g
i.z = d
i.w = m
i.y = j
i.r = g
l.z = d
l.w = g
l.y = j
l.r = m
assert c.t.z.r.t.w.txt == "g"