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

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

class C:
    def __init__(self, txt: str):
        self.w: E = None
        self.t: E = None
        self.q: A = None
        self.u: F = None
        self.r: E = None
        self.txt = txt

class D:
    def __init__(self, txt: str):
        self.p: B = None
        self.s: A = None
        self.u: F = None
        self.z: A = None
        self.x: A = None
        self.txt = txt

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

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

a = A("a")
l = B("l")
h = C("h")
d = D("d")
g = E("g")
n = F("n")
b = E("b")

a.q = n
a.x = d
a.r = d
a.o = h
l.o = a
h.w = b
h.t = b
h.q = a
h.u = n
h.r = g
d.p = l
d.s = a
d.z = a
d.x = a
d.u = n
g.z = d
g.v = d
g.q = d
g.r = l
n.o = d
b.z = d
b.v = d
b.q = d
b.r = l
assert b.v.p.o.q.o.txt == "
class A:
    def __init__(self, txt: str):
        self.q: F = None
        self.x: D = None
        self.r: D = None
        self.o: C = None
        self.txt = txt

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

class C:
    def __init__(self, txt: str):
        self.w: E = None
        self.t: E = None
        self.q: A = None
        self.u: F = None
        self.r: E = None
        self.txt = txt

class D:
    def __init__(self, txt: str):
        self.p: B = None
        self.s: A = None
        self.u: F = None
        self.z: A = None
        self.x: A = None
        self.txt = txt

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

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

a = A("a")
l = B("l")
h = C("h")
d = D("d")
g = E("g")
n = F("n")
b = E("b")

a.q = n
a.x = d
a.r = d
a.o = h
l.o = a
h.w = b
h.t = b
h.q = a
h.u = n
h.r = g
d.p = l
d.s = a
d.z = a
d.x = a
d.u = n
g.z = d
g.v = d
g.q = d
g.r = l
n.o = d
b.z = d
b.v = d
b.q = d
b.r = l
assert b.v.p.o.q.o.txt == "d"