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

class B:
    def __init__(self, txt: str):
        self.u: C = None
        self.txt = txt

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

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

class E:
    def __init__(self, txt: str):
        self.y: C = None
        self.txt = txt

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

h = A("h")
i = B("i")
e = C("e")
d = D("d")
m = E("m")
j = F("j")
g = F("g")
n = A("n")
l = F("l")
c = A("c")

h.r = d
i.u = e
e.p = c
e.v = l
e.x = i
d.r = l
d.p = l
d.x = i
m.y = e
j.t = i
j.q = e
g.t = i
g.q = e
n.r = d
l.t = i
l.q = e
c.r = d
assert h.r.r.q.p.r.r.q.v.txt == "
class A:
    def __init__(self, txt: str):
        self.r: D = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.u: C = None
        self.txt = txt

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

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

class E:
    def __init__(self, txt: str):
        self.y: C = None
        self.txt = txt

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

h = A("h")
i = B("i")
e = C("e")
d = D("d")
m = E("m")
j = F("j")
g = F("g")
n = A("n")
l = F("l")
c = A("c")

h.r = d
i.u = e
e.p = c
e.v = l
e.x = i
d.r = l
d.p = l
d.x = i
m.y = e
j.t = i
j.q = e
g.t = i
g.q = e
n.r = d
l.t = i
l.q = e
c.r = d
assert h.r.r.q.p.r.r.q.v.txt == "l"