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

class B:
    def __init__(self, txt: str):
        self.u: D = None
        self.q: G = None
        self.y: F = None
        self.r: A = None
        self.p: D = None
        self.txt = txt

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

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

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

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

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

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

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

class B:
    def __init__(self, txt: str):
        self.u: D = None
        self.q: G = None
        self.y: F = None
        self.r: A = None
        self.p: D = None
        self.txt = txt

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

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

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

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

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

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

d.u = n
d.s = a
g.u = n
g.p = n
g.q = e
g.y = h
g.r = d
a.s = n
a.x = d
n.o = k
n.r = a
n.y = g
n.t = e
k.z = a
k.t = e
k.y = h
h.s = d
h.q = d
e.s = d
assert n.r.s.y.y.txt == "h"