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

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

class C:
    def __init__(self, txt: str):
        self.s: E = None
        self.x: F = None
        self.o: C = None
        self.w: A = None
        self.txt = txt

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

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

class F:
    def __init__(self, txt: str):
        self.u: B = None
        self.w: E = None
        self.r: E = None
        self.t: A = None
        self.q: A = None
        self.z: B = None
        self.txt = txt

n = A("n")
f = B("f")
c = C("c")
i = D("i")
m = E("m")
a = F("a")
h = C("h")
d = B("d")

n.s = i
n.x = i
f.x = d
f.q = m
f.v = n
c.s = m
c.x = a
c.o = h
c.w = n
i.r = a
m.r = d
a.u = d
a.z = d
a.w = m
a.r = m
a.t = n
a.q = n
h.s = m
h.x = a
h.o = c
h.w = n
d.x = f
d.q = m
d.v = n
assert f.x.q.r.txt == "
class A:
    def __init__(self, txt: str):
        self.s: D = None
        self.x: D = None
        self.txt = txt

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

class C:
    def __init__(self, txt: str):
        self.s: E = None
        self.x: F = None
        self.o: C = None
        self.w: A = None
        self.txt = txt

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

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

class F:
    def __init__(self, txt: str):
        self.u: B = None
        self.w: E = None
        self.r: E = None
        self.t: A = None
        self.q: A = None
        self.z: B = None
        self.txt = txt

n = A("n")
f = B("f")
c = C("c")
i = D("i")
m = E("m")
a = F("a")
h = C("h")
d = B("d")

n.s = i
n.x = i
f.x = d
f.q = m
f.v = n
c.s = m
c.x = a
c.o = h
c.w = n
i.r = a
m.r = d
a.u = d
a.z = d
a.w = m
a.r = m
a.t = n
a.q = n
h.s = m
h.x = a
h.o = c
h.w = n
d.x = f
d.q = m
d.v = n
assert f.x.q.r.txt == "d"