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

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

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

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

c = A("c")
g = B("g")
a = C("a")
f = D("f")
i = A("i")
e = C("e")
k = B("k")
b = D("b")
d = A("d")
l = D("l")

c.p = a
c.z = g
c.q = b
g.p = l
a.o = i
f.o = a
f.x = g
f.q = k
i.p = a
i.z = k
i.q = b
e.o = c
k.p = b
b.o = e
b.x = k
b.q = k
d.p = e
d.z = k
d.q = f
l.o = a
l.x = k
l.q = g
assert d.p.o.q.txt == "
class A:
    def __init__(self, txt: str):
        self.p: C = None
        self.z: B = None
        self.q: D = None
        self.txt = txt

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

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

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

c = A("c")
g = B("g")
a = C("a")
f = D("f")
i = A("i")
e = C("e")
k = B("k")
b = D("b")
d = A("d")
l = D("l")

c.p = a
c.z = g
c.q = b
g.p = l
a.o = i
f.o = a
f.x = g
f.q = k
i.p = a
i.z = k
i.q = b
e.o = c
k.p = b
b.o = e
b.x = k
b.q = k
d.p = e
d.z = k
d.q = f
l.o = a
l.x = k
l.q = g
assert d.p.o.q.txt == "b"