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

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

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

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

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

j.q = c
b.q = g
b.p = c
b.o = j
b.w = k
k.y = j
h.z = c
d.q = j
d.p = c
d.o = g
d.w = k
l.q = j
l.o = j
l.p = h
l.w = k
c.z = h
g.q = c
a.q = j
a.p = h
a.o = g
a.w = k
assert l.o.q.z.z.txt == "
class A:
    def __init__(self, txt: str):
        self.q: D = None
        self.txt = txt

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

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

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

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

j.q = c
b.q = g
b.p = c
b.o = j
b.w = k
k.y = j
h.z = c
d.q = j
d.p = c
d.o = g
d.w = k
l.q = j
l.o = j
l.p = h
l.w = k
c.z = h
g.q = c
a.q = j
a.p = h
a.o = g
a.w = k
assert l.o.q.z.z.txt == "c"