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

class B:
    def __init__(self, txt: str):
        self.p: E = None
        self.u: G = None
        self.txt = txt

class C:
    def __init__(self, txt: str):
        self.z: D = None
        self.t: F = None
        self.o: D = None
        self.r: E = None
        self.txt = txt

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

class E:
    def __init__(self, txt: str):
        self.p: G = None
        self.o: B = None
        self.w: G = None
        self.x: C = None
        self.txt = txt

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

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

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

a.r = d
b.p = m
b.u = d
n.z = l
n.o = l
n.t = h
n.r = m
l.o = a
m.p = d
m.o = b
m.w = c
m.x = n
h.w = a
h.z = a
h.y = j
h.u = c
d.q = l
j.z = l
j.o = l
j.t = h
j.r = m
c.q = l
assert h.u.q.o.r.txt == "
class A:
    def __init__(self, txt: str):
        self.r: G = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.p: E = None
        self.u: G = None
        self.txt = txt

class C:
    def __init__(self, txt: str):
        self.z: D = None
        self.t: F = None
        self.o: D = None
        self.r: E = None
        self.txt = txt

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

class E:
    def __init__(self, txt: str):
        self.p: G = None
        self.o: B = None
        self.w: G = None
        self.x: C = None
        self.txt = txt

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

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

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

a.r = d
b.p = m
b.u = d
n.z = l
n.o = l
n.t = h
n.r = m
l.o = a
m.p = d
m.o = b
m.w = c
m.x = n
h.w = a
h.z = a
h.y = j
h.u = c
d.q = l
j.z = l
j.o = l
j.t = h
j.r = m
c.q = l
assert h.u.q.o.r.txt == "d"