class A:
    def __init__(self, txt: str):
        self.q: C = None
        self.y: E = None
        self.txt = txt

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

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

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

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

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

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

j = A("j")
n = B("n")
c = C("c")
d = D("d")
b = E("b")
g = F("g")
h = G("h")
k = G("k")
i = G("i")

j.q = c
j.y = b
n.x = d
n.s = i
c.u = d
c.w = i
d.u = n
b.o = j
b.r = g
b.w = d
g.x = j
g.w = c
g.v = k
h.x = g
k.x = g
i.x = g
assert d.u.x.u.txt == "
class A:
    def __init__(self, txt: str):
        self.q: C = None
        self.y: E = None
        self.txt = txt

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

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

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

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

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

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

j = A("j")
n = B("n")
c = C("c")
d = D("d")
b = E("b")
g = F("g")
h = G("h")
k = G("k")
i = G("i")

j.q = c
j.y = b
n.x = d
n.s = i
c.u = d
c.w = i
d.u = n
b.o = j
b.r = g
b.w = d
g.x = j
g.w = c
g.v = k
h.x = g
k.x = g
i.x = g
assert d.u.x.u.txt == "n"