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

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

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

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

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

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

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

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

d.y = m
d.x = h
b.v = h
b.s = l
b.r = l
m.r = f
m.z = d
m.x = j
h.q = f
h.p = f
j.r = l
l.y = j
l.w = f
f.s = l
assert f.s.y.r.w.s.w.s.txt == "
class A:
    def __init__(self, txt: str):
        self.y: C = None
        self.x: D = None
        self.txt = txt

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

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

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

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

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

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

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

d.y = m
d.x = h
b.v = h
b.s = l
b.r = l
m.r = f
m.z = d
m.x = j
h.q = f
h.p = f
j.r = l
l.y = j
l.w = f
f.s = l
assert f.s.y.r.w.s.w.s.txt == "l"