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

class B:
    def __init__(self, txt: str):
        self.x: D = None
        self.y: E = None
        self.t: F = None
        self.s: F = None
        self.o: C = None
        self.txt = txt

class C:
    def __init__(self, txt: str):
        self.v: B = None
        self.y: B = None
        self.r: B = None
        self.x: B = None
        self.txt = txt

class D:
    def __init__(self, txt: str):
        self.w: E = None
        self.p: E = None
        self.s: B = None
        self.y: B = None
        self.t: F = None
        self.txt = txt

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

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

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

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

class B:
    def __init__(self, txt: str):
        self.x: D = None
        self.y: E = None
        self.t: F = None
        self.s: F = None
        self.o: C = None
        self.txt = txt

class C:
    def __init__(self, txt: str):
        self.v: B = None
        self.y: B = None
        self.r: B = None
        self.x: B = None
        self.txt = txt

class D:
    def __init__(self, txt: str):
        self.w: E = None
        self.p: E = None
        self.s: B = None
        self.y: B = None
        self.t: F = None
        self.txt = txt

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

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

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

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