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

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

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

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

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

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

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

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

b.t = k
f.z = m
f.v = m
d.v = m
k.q = m
c.s = k
c.r = k
m.s = k
m.q = f
m.z = a
a.s = k
a.y = d
assert m.s.q.z.y.v.q.v.txt == "
class A:
    def __init__(self, txt: str):
        self.t: D = None
        self.txt = txt

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

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

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

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

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

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

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

b.t = k
f.z = m
f.v = m
d.v = m
k.q = m
c.s = k
c.r = k
m.s = k
m.q = f
m.z = a
a.s = k
a.y = d
assert m.s.q.z.y.v.q.v.txt == "m"