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

class B:
    def __init__(self, txt: str):
        self.r: C = None
        self.z: D = None
        self.y: F = None
        self.q: F = None
        self.p: C = None
        self.w: C = None
        self.txt = txt

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

class D:
    def __init__(self, txt: str):
        self.v: A = None
        self.r: B = None
        self.y: B = None
        self.t: F = None
        self.txt = txt

class E:
    def __init__(self, txt: str):
        self.u: A = None
        self.o: D = None
        self.txt = txt

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

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

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

class B:
    def __init__(self, txt: str):
        self.r: C = None
        self.z: D = None
        self.y: F = None
        self.q: F = None
        self.p: C = None
        self.w: C = None
        self.txt = txt

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

class D:
    def __init__(self, txt: str):
        self.v: A = None
        self.r: B = None
        self.y: B = None
        self.t: F = None
        self.txt = txt

class E:
    def __init__(self, txt: str):
        self.u: A = None
        self.o: D = None
        self.txt = txt

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

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

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