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

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

class C:
    def __init__(self, txt: str):
        self.o: E = None
        self.u: E = None
        self.z: G = None
        self.v: F = None
        self.txt = txt

class D:
    def __init__(self, txt: str):
        self.u: B = None
        self.z: A = None
        self.v: B = None
        self.o: C = None
        self.txt = txt

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

class F:
    def __init__(self, txt: str):
        self.z: C = None
        self.q: G = None
        self.v: C = None
        self.o: D = None
        self.y: E = None
        self.txt = txt

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

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

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

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

class C:
    def __init__(self, txt: str):
        self.o: E = None
        self.u: E = None
        self.z: G = None
        self.v: F = None
        self.txt = txt

class D:
    def __init__(self, txt: str):
        self.u: B = None
        self.z: A = None
        self.v: B = None
        self.o: C = None
        self.txt = txt

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

class F:
    def __init__(self, txt: str):
        self.z: C = None
        self.q: G = None
        self.v: C = None
        self.o: D = None
        self.y: E = None
        self.txt = txt

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

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

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