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

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

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

g = A("g")
b = B("b")
i = C("i")
f = C("f")
e = B("e")
l = C("l")
m = B("m")
h = B("h")
a = A("a")
d = B("d")

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

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

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

g = A("g")
b = B("b")
i = C("i")
f = C("f")
e = B("e")
l = C("l")
m = B("m")
h = B("h")
a = A("a")
d = B("d")

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