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

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

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

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

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

class F:
    def __init__(self, txt: str):
        self.r: A = None
        self.w: A = None
        self.s: B = None
        self.p: B = None
        self.txt = txt

b = A("b")
a = B("a")
g = C("g")
d = D("d")
k = E("k")
f = F("f")

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

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

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

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

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

class F:
    def __init__(self, txt: str):
        self.r: A = None
        self.w: A = None
        self.s: B = None
        self.p: B = None
        self.txt = txt

b = A("b")
a = B("a")
g = C("g")
d = D("d")
k = E("k")
f = F("f")

b.z = g
a.z = g
a.t = g
a.u = d
g.q = b
g.y = b
g.z = d
g.p = d
g.x = f
g.s = f
d.o = b
d.q = b
d.x = f
d.r = g
d.v = a
k.p = a
f.r = b
f.w = b
f.s = a
f.p = a
assert f.r.z.q.z.p.txt == "d"