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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

m.s = b
d.y = h
h.v = m
b.y = j
k.u = m
k.p = h
k.o = g
g.r = d
j.u = h
j.y = g
assert d.y.v.s.y.y.r.y.txt == "h"