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

class B:
    def __init__(self, txt: str):
        self.x: E = None
        self.v: D = None
        self.q: A = None
        self.r: D = None
        self.t: F = None
        self.txt = txt

class C:
    def __init__(self, txt: str):
        self.u: B = None
        self.v: E = None
        self.t: B = None
        self.txt = txt

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

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

class F:
    def __init__(self, txt: str):
        self.x: C = None
        self.z: B = None
        self.o: A = None
        self.s: D = None
        self.txt = txt

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

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

m.z = l
n.x = l
n.v = b
n.r = b
n.q = m
n.t = j
a.u = n
a.t = n
a.v = l
b.o = m
b.t = a
l.v = m
l.p = n
j.x = a
j.z = n
j.o = m
j.s = b
f.x = n
f.s = l
assert b.t.v.p.t.x.v.txt == "
class A:
    def __init__(self, txt: str):
        self.z: E = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.x: E = None
        self.v: D = None
        self.q: A = None
        self.r: D = None
        self.t: F = None
        self.txt = txt

class C:
    def __init__(self, txt: str):
        self.u: B = None
        self.v: E = None
        self.t: B = None
        self.txt = txt

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

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

class F:
    def __init__(self, txt: str):
        self.x: C = None
        self.z: B = None
        self.o: A = None
        self.s: D = None
        self.txt = txt

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

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

m.z = l
n.x = l
n.v = b
n.r = b
n.q = m
n.t = j
a.u = n
a.t = n
a.v = l
b.o = m
b.t = a
l.v = m
l.p = n
j.x = a
j.z = n
j.o = m
j.s = b
f.x = n
f.s = l
assert b.t.v.p.t.x.v.txt == "l"