class A:
    def __init__(self, txt: str):
        self.u: B = None
        self.o: B = None
        self.r: E = None
        self.x: B = None
        self.txt = txt

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

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

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

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

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

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

a.u = n
a.o = n
a.x = n
a.r = d
n.q = j
j.y = e
f.r = a
k.q = n
c.z = f
c.u = a
c.q = e
c.x = h
d.q = n
e.u = n
e.o = n
e.x = n
e.r = d
h.z = f
h.u = a
h.q = e
h.x = c
assert j.y.u.q.y.r.q.q.y.r.txt == "
class A:
    def __init__(self, txt: str):
        self.u: B = None
        self.o: B = None
        self.r: E = None
        self.x: B = None
        self.txt = txt

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

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

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

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

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

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

a.u = n
a.o = n
a.x = n
a.r = d
n.q = j
j.y = e
f.r = a
k.q = n
c.z = f
c.u = a
c.q = e
c.x = h
d.q = n
e.u = n
e.o = n
e.x = n
e.r = d
h.z = f
h.u = a
h.q = e
h.x = c
assert j.y.u.q.y.r.q.q.y.r.txt == "d"