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

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

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

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

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

c.q = d
c.p = l
c.v = g
k.v = g
k.q = g
h.q = g
h.v = g
m.z = h
m.p = d
f.q = k
f.v = g
b.q = m
b.p = l
b.v = g
d.z = f
d.p = m
l.q = d
l.p = c
l.v = k
j.q = g
j.v = k
g.v = k
g.q = k
assert m.p.z.v.v.q.q.txt == "
class A:
    def __init__(self, txt: str):
        self.q: D = None
        self.p: A = None
        self.v: B = None
        self.txt = txt

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

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

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

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

c.q = d
c.p = l
c.v = g
k.v = g
k.q = g
h.q = g
h.v = g
m.z = h
m.p = d
f.q = k
f.v = g
b.q = m
b.p = l
b.v = g
d.z = f
d.p = m
l.q = d
l.p = c
l.v = k
j.q = g
j.v = k
g.v = k
g.q = k
assert m.p.z.v.v.q.q.txt == "k"