class A:
    def __init__(self, txt: str):
        self.u: F = None
        self.y: F = None
        self.r: C = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.o: C = None
        self.txt = txt

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

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

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

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

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

g.u = a
g.y = a
g.r = d
c.o = d
m.q = c
m.z = h
n.z = a
n.y = c
n.p = g
h.v = d
h.x = j
h.y = a
a.p = h
a.x = g
j.q = c
j.z = h
d.q = c
d.z = h
assert n.y.o.z.y.p.x.q.o.txt == "
class A:
    def __init__(self, txt: str):
        self.u: F = None
        self.y: F = None
        self.r: C = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.o: C = None
        self.txt = txt

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

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

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

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

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

g.u = a
g.y = a
g.r = d
c.o = d
m.q = c
m.z = h
n.z = a
n.y = c
n.p = g
h.v = d
h.x = j
h.y = a
a.p = h
a.x = g
j.q = c
j.z = h
d.q = c
d.z = h
assert n.y.o.z.y.p.x.q.o.txt == "d"