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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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