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

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

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

class D:
    def __init__(self, txt: str):
        self.q: D = None
        self.u: C = None
        self.p: D = None
        self.t: C = None
        self.txt = txt

c = A("c")
g = B("g")
k = C("k")
e = D("e")
l = D("l")
n = D("n")
d = D("d")
h = A("h")
m = A("m")

c.q = k
c.u = m
c.v = n
g.t = k
g.w = e
g.q = c
k.o = n
e.q = l
e.u = k
e.t = k
e.p = n
l.q = e
l.u = k
l.t = k
l.p = d
n.q = l
n.u = k
n.t = k
n.p = d
d.q = l
d.u = k
d.t = k
d.p = n
h.q = k
h.u = m
h.v = d
m.q = k
m.u = h
m.v = l
assert l.p.q.u.o.t.o.txt == "
class A:
    def __init__(self, txt: str):
        self.q: C = None
        self.u: A = None
        self.v: D = None
        self.txt = txt

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

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

class D:
    def __init__(self, txt: str):
        self.q: D = None
        self.u: C = None
        self.p: D = None
        self.t: C = None
        self.txt = txt

c = A("c")
g = B("g")
k = C("k")
e = D("e")
l = D("l")
n = D("n")
d = D("d")
h = A("h")
m = A("m")

c.q = k
c.u = m
c.v = n
g.t = k
g.w = e
g.q = c
k.o = n
e.q = l
e.u = k
e.t = k
e.p = n
l.q = e
l.u = k
l.t = k
l.p = d
n.q = l
n.u = k
n.t = k
n.p = d
d.q = l
d.u = k
d.t = k
d.p = n
h.q = k
h.u = m
h.v = d
m.q = k
m.u = h
m.v = l
assert l.p.q.u.o.t.o.txt == "n"