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

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

class C:
    def __init__(self, txt: str):
        self.x: E = None
        self.txt = txt

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

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

class F:
    def __init__(self, txt: str):
        self.p: E = None
        self.r: C = None
        self.txt = txt

d = A("d")
j = B("j")
n = C("n")
e = D("e")
f = E("f")
h = F("h")

d.s = e
j.p = h
j.q = h
j.u = n
n.x = f
e.x = j
e.y = n
e.t = d
e.z = d
e.p = h
f.y = h
f.x = n
f.z = n
f.s = e
f.t = j
h.p = f
h.r = n
assert f.s.y.x.z.x.s.txt == "
class A:
    def __init__(self, txt: str):
        self.s: D = None
        self.txt = txt

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

class C:
    def __init__(self, txt: str):
        self.x: E = None
        self.txt = txt

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

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

class F:
    def __init__(self, txt: str):
        self.p: E = None
        self.r: C = None
        self.txt = txt

d = A("d")
j = B("j")
n = C("n")
e = D("e")
f = E("f")
h = F("h")

d.s = e
j.p = h
j.q = h
j.u = n
n.x = f
e.x = j
e.y = n
e.t = d
e.z = d
e.p = h
f.y = h
f.x = n
f.z = n
f.s = e
f.t = j
h.p = f
h.r = n
assert f.s.y.x.z.x.s.txt == "e"