class A:
    def __init__(self, txt: str):
        self.o: B = None
        self.w: B = None
        self.z: B = None
        self.txt = txt

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

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

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

c = A("c")
n = B("n")
g = C("g")
a = D("a")
d = D("d")
k = D("k")
m = D("m")

c.o = n
c.w = n
c.z = n
n.o = k
g.v = n
g.q = c
g.o = m
a.r = c
a.p = c
d.r = c
d.p = c
k.r = c
k.p = c
m.r = c
m.p = c
assert c.z.o.p.w.o.p.txt == "
class A:
    def __init__(self, txt: str):
        self.o: B = None
        self.w: B = None
        self.z: B = None
        self.txt = txt

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

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

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

c = A("c")
n = B("n")
g = C("g")
a = D("a")
d = D("d")
k = D("k")
m = D("m")

c.o = n
c.w = n
c.z = n
n.o = k
g.v = n
g.q = c
g.o = m
a.r = c
a.p = c
d.r = c
d.p = c
k.r = c
k.p = c
m.r = c
m.p = c
assert c.z.o.p.w.o.p.txt == "c"