class A:
    def __init__(self, txt: str):
        self.r: E = None
        self.txt = txt

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

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

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

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

class F:
    def __init__(self, txt: str):
        self.t: E = None
        self.z: D = None
        self.txt = txt

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

g.r = k
d.r = l
d.u = m
d.t = k
d.p = k
d.x = g
a.u = g
l.q = k
l.x = k
l.y = g
l.u = m
k.q = d
k.u = d
k.t = d
k.z = a
m.t = k
m.z = l
f.r = l
f.u = m
f.t = k
f.p = k
f.x = g
assert d.t.z.u.r.q.t.z.txt == "
class A:
    def __init__(self, txt: str):
        self.r: E = None
        self.txt = txt

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

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

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

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

class F:
    def __init__(self, txt: str):
        self.t: E = None
        self.z: D = None
        self.txt = txt

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

g.r = k
d.r = l
d.u = m
d.t = k
d.p = k
d.x = g
a.u = g
l.q = k
l.x = k
l.y = g
l.u = m
k.q = d
k.u = d
k.t = d
k.z = a
m.t = k
m.z = l
f.r = l
f.u = m
f.t = k
f.p = k
f.x = g
assert d.t.z.u.r.q.t.z.txt == "a"