class A:
    def __init__(self, txt: str):
        self.v: B = None
        self.y: E = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.s: D = None
        self.y: A = None
        self.q: C = None
        self.u: A = None
        self.p: A = None
        self.txt = txt

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

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

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

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

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

g.v = a
g.y = m
a.s = h
a.y = g
a.u = g
a.p = g
a.q = l
l.w = a
l.p = d
h.u = g
d.r = g
f.q = h
f.s = d
f.y = g
f.r = g
m.r = g
b.w = a
b.p = d
assert g.v.q.p.r.txt == "
class A:
    def __init__(self, txt: str):
        self.v: B = None
        self.y: E = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.s: D = None
        self.y: A = None
        self.q: C = None
        self.u: A = None
        self.p: A = None
        self.txt = txt

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

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

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

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

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

g.v = a
g.y = m
a.s = h
a.y = g
a.u = g
a.p = g
a.q = l
l.w = a
l.p = d
h.u = g
d.r = g
f.q = h
f.s = d
f.y = g
f.r = g
m.r = g
b.w = a
b.p = d
assert g.v.q.p.r.txt == "g"