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

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

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

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

m = A("m")
d = B("d")
c = C("c")
e = D("e")
g = C("g")
j = A("j")
k = C("k")

m.o = g
m.p = c
d.z = g
c.r = k
c.o = e
c.v = m
c.z = d
e.q = j
g.r = k
g.o = e
g.v = j
g.z = d
j.o = k
j.p = k
k.r = c
k.o = e
k.v = j
k.z = d
assert k.z.z.o.q.txt == "
class A:
    def __init__(self, txt: str):
        self.o: C = None
        self.p: C = None
        self.txt = txt

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

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

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

m = A("m")
d = B("d")
c = C("c")
e = D("e")
g = C("g")
j = A("j")
k = C("k")

m.o = g
m.p = c
d.z = g
c.r = k
c.o = e
c.v = m
c.z = d
e.q = j
g.r = k
g.o = e
g.v = j
g.z = d
j.o = k
j.p = k
k.r = c
k.o = e
k.v = j
k.z = d
assert k.z.z.o.q.txt == "j"