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

class B:
    def __init__(self, txt: str):
        self.s: A = None
        self.v: G = None
        self.r: D = None
        self.t: D = None
        self.q: C = None
        self.p: F = None
        self.txt = txt

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

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

class E:
    def __init__(self, txt: str):
        self.v: F = None
        self.o: B = None
        self.q: F = None
        self.txt = txt

class F:
    def __init__(self, txt: str):
        self.p: C = None
        self.txt = txt

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

g = A("g")
h = B("h")
d = C("d")
l = D("l")
j = E("j")
n = F("n")
k = G("k")

g.y = l
h.s = g
h.v = k
h.r = l
h.t = l
h.q = d
h.p = n
d.v = h
d.q = h
l.y = g
j.v = n
j.q = n
j.o = h
n.p = d
k.t = d
k.s = g
assert j.v.p.v.q.q.t.y.txt == "
class A:
    def __init__(self, txt: str):
        self.y: D = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.s: A = None
        self.v: G = None
        self.r: D = None
        self.t: D = None
        self.q: C = None
        self.p: F = None
        self.txt = txt

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

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

class E:
    def __init__(self, txt: str):
        self.v: F = None
        self.o: B = None
        self.q: F = None
        self.txt = txt

class F:
    def __init__(self, txt: str):
        self.p: C = None
        self.txt = txt

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

g = A("g")
h = B("h")
d = C("d")
l = D("l")
j = E("j")
n = F("n")
k = G("k")

g.y = l
h.s = g
h.v = k
h.r = l
h.t = l
h.q = d
h.p = n
d.v = h
d.q = h
l.y = g
j.v = n
j.q = n
j.o = h
n.p = d
k.t = d
k.s = g
assert j.v.p.v.q.q.t.y.txt == "g"