class A:
    def __init__(self, txt: str):
        self.v: F = None
        self.w: D = None
        self.txt = txt

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

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

class D:
    def __init__(self, txt: str):
        self.v: A = None
        self.w: F = None
        self.r: C = None
        self.p: E = None
        self.u: F = None
        self.txt = txt

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

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

class G:
    def __init__(self, txt: str):
        self.w: A = None
        self.r: B = None
        self.txt = txt

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

f.v = m
f.w = a
g.v = d
l.v = g
l.p = a
a.v = f
a.w = m
a.u = m
a.r = l
a.p = b
b.z = g
b.s = g
b.o = m
b.x = d
m.q = a
m.w = a
d.w = f
d.r = g
assert m.w.u.q.p.txt == "
class A:
    def __init__(self, txt: str):
        self.v: F = None
        self.w: D = None
        self.txt = txt

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

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

class D:
    def __init__(self, txt: str):
        self.v: A = None
        self.w: F = None
        self.r: C = None
        self.p: E = None
        self.u: F = None
        self.txt = txt

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

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

class G:
    def __init__(self, txt: str):
        self.w: A = None
        self.r: B = None
        self.txt = txt

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

f.v = m
f.w = a
g.v = d
l.v = g
l.p = a
a.v = f
a.w = m
a.u = m
a.r = l
a.p = b
b.z = g
b.s = g
b.o = m
b.x = d
m.q = a
m.w = a
d.w = f
d.r = g
assert m.w.u.q.p.txt == "b"