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

class B:
    def __init__(self, txt: str):
        self.q: D = None
        self.o: A = None
        self.u: D = None
        self.p: A = None
        self.t: A = None
        self.w: E = None
        self.txt = txt

class C:
    def __init__(self, txt: str):
        self.s: F = None
        self.r: F = None
        self.v: A = None
        self.q: B = None
        self.o: B = None
        self.txt = txt

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

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

class F:
    def __init__(self, txt: str):
        self.z: B = None
        self.txt = txt

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

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

class B:
    def __init__(self, txt: str):
        self.q: D = None
        self.o: A = None
        self.u: D = None
        self.p: A = None
        self.t: A = None
        self.w: E = None
        self.txt = txt

class C:
    def __init__(self, txt: str):
        self.s: F = None
        self.r: F = None
        self.v: A = None
        self.q: B = None
        self.o: B = None
        self.txt = txt

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

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

class F:
    def __init__(self, txt: str):
        self.z: B = None
        self.txt = txt

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

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