class A:
    def __init__(self, txt: str):
        self.t: B = None
        self.y: E = None
        self.txt = txt

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

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

class D:
    def __init__(self, txt: str):
        self.w: A = None
        self.x: E = None
        self.p: F = None
        self.u: A = None
        self.y: F = None
        self.txt = txt

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

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

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

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

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

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

class D:
    def __init__(self, txt: str):
        self.w: A = None
        self.x: E = None
        self.p: F = None
        self.u: A = None
        self.y: F = None
        self.txt = txt

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

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

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

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