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

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

class C:
    def __init__(self, txt: str):
        self.p: C = None
        self.w: D = None
        self.txt = txt

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

class E:
    def __init__(self, txt: str):
        self.w: B = None
        self.q: D = None
        self.txt = txt

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

h = A("h")
k = B("k")
e = C("e")
m = D("m")
d = E("d")
g = F("g")
f = B("f")
n = C("n")

h.x = g
k.r = d
k.u = d
k.p = n
e.p = n
e.w = m
m.t = h
m.q = h
m.w = g
m.s = e
m.p = d
d.w = f
d.q = m
g.t = e
g.r = f
f.r = d
f.u = d
f.p = e
n.p = e
n.w = m
assert d.q.q.x.t.w.t.x.r.txt == "
class A:
    def __init__(self, txt: str):
        self.x: F = None
        self.txt = txt

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

class C:
    def __init__(self, txt: str):
        self.p: C = None
        self.w: D = None
        self.txt = txt

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

class E:
    def __init__(self, txt: str):
        self.w: B = None
        self.q: D = None
        self.txt = txt

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

h = A("h")
k = B("k")
e = C("e")
m = D("m")
d = E("d")
g = F("g")
f = B("f")
n = C("n")

h.x = g
k.r = d
k.u = d
k.p = n
e.p = n
e.w = m
m.t = h
m.q = h
m.w = g
m.s = e
m.p = d
d.w = f
d.q = m
g.t = e
g.r = f
f.r = d
f.u = d
f.p = e
n.p = e
n.w = m
assert d.q.q.x.t.w.t.x.r.txt == "f"