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

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

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

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

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

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

h = A("h")
i = B("i")
f = C("f")
n = D("n")
j = E("j")
l = F("l")
m = E("m")

h.s = f
i.u = m
f.r = n
f.s = n
f.y = n
f.x = j
f.z = i
n.u = i
n.t = h
j.q = l
l.v = h
l.r = h
l.x = n
l.q = n
l.z = f
m.q = l
assert f.x.q.r.s.txt == "
class A:
    def __init__(self, txt: str):
        self.s: C = None
        self.txt = txt

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

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

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

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

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

h = A("h")
i = B("i")
f = C("f")
n = D("n")
j = E("j")
l = F("l")
m = E("m")

h.s = f
i.u = m
f.r = n
f.s = n
f.y = n
f.x = j
f.z = i
n.u = i
n.t = h
j.q = l
l.v = h
l.r = h
l.x = n
l.q = n
l.z = f
m.q = l
assert f.x.q.r.s.txt == "f"