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

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

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

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

c = A("c")
e = B("e")
l = C("l")
g = D("g")
n = B("n")
b = C("b")
m = A("m")

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

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

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

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

c = A("c")
e = B("e")
l = C("l")
g = D("g")
n = B("n")
b = C("b")
m = A("m")

c.o = m
c.z = m
c.q = b
c.v = g
e.q = c
e.s = c
e.p = m
e.t = n
l.w = g
g.p = c
n.q = m
n.p = c
n.s = c
n.t = e
b.w = g
m.o = c
m.z = c
m.q = b
m.v = g
assert c.v.p.o.q.w.txt == "g"