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

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

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

class D:
    def __init__(self, txt: str):
        self.r: C = None
        self.o: B = None
        self.u: G = None
        self.z: A = None
        self.q: E = None
        self.p: A = None
        self.s: B = None
        self.txt = txt

class E:
    def __init__(self, txt: str):
        self.y: G = None
        self.p: B = None
        self.u: G = None
        self.v: A = None
        self.w: C = None
        self.txt = txt

class F:
    def __init__(self, txt: str):
        self.o: G = None
        self.w: G = None
        self.txt = txt

class G:
    def __init__(self, txt: str):
        self.v: A = None
        self.w: B = None
        self.txt = txt

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

l.o = c
l.p = j
d.y = k
d.z = k
c.r = l
j.r = c
j.o = d
j.s = d
j.u = m
j.z = l
j.p = l
j.q = k
k.y = m
k.u = m
k.p = d
k.v = l
k.w = c
a.o = m
a.w = m
m.v = l
m.w = d
assert j.q.w.r.p.q.txt == "
class A:
    def __init__(self, txt: str):
        self.o: C = None
        self.p: D = None
        self.txt = txt

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

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

class D:
    def __init__(self, txt: str):
        self.r: C = None
        self.o: B = None
        self.u: G = None
        self.z: A = None
        self.q: E = None
        self.p: A = None
        self.s: B = None
        self.txt = txt

class E:
    def __init__(self, txt: str):
        self.y: G = None
        self.p: B = None
        self.u: G = None
        self.v: A = None
        self.w: C = None
        self.txt = txt

class F:
    def __init__(self, txt: str):
        self.o: G = None
        self.w: G = None
        self.txt = txt

class G:
    def __init__(self, txt: str):
        self.v: A = None
        self.w: B = None
        self.txt = txt

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

l.o = c
l.p = j
d.y = k
d.z = k
c.r = l
j.r = c
j.o = d
j.s = d
j.u = m
j.z = l
j.p = l
j.q = k
k.y = m
k.u = m
k.p = d
k.v = l
k.w = c
a.o = m
a.w = m
m.v = l
m.w = d
assert j.q.w.r.p.q.txt == "k"