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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

b.v = a
a.q = l
d.r = f
d.w = g
d.s = g
l.y = f
l.p = b
e.w = h
e.v = h
e.p = a
f.x = g
g.t = d
g.s = l
h.w = e
h.v = e
h.p = a
assert a.q.p.v.q.p.v.txt == "a"