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

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

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

class D:
    def __init__(self, txt: str):
        self.z: C = None
        self.p: A = None
        self.w: G = None
        self.s: G = None
        self.txt = txt

class E:
    def __init__(self, txt: str):
        self.r: A = None
        self.u: F = None
        self.x: F = None
        self.o: A = None
        self.p: D = None
        self.s: F = None
        self.txt = txt

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

class G:
    def __init__(self, txt: str):
        self.z: E = None
        self.s: A = None
        self.t: C = None
        self.r: E = None
        self.q: E = None
        self.txt = txt

d = A("d")
c = B("c")
h = C("h")
m = D("m")
a = E("a")
j = F("j")
g = G("g")
l = F("l")

d.p = h
d.r = j
c.s = d
h.y = m
h.p = a
h.q = c
h.u = c
h.o = g
m.z = h
m.p = d
m.w = g
m.s = g
a.r = d
a.o = d
a.u = j
a.x = j
a.s = j
a.p = m
j.r = d
g.z = a
g.r = a
g.q = a
g.s = d
g.t = h
l.r = d
assert d.r.r.p.o.t.q.txt == "
class A:
    def __init__(self, txt: str):
        self.p: C = None
        self.r: F = None
        self.txt = txt

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

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

class D:
    def __init__(self, txt: str):
        self.z: C = None
        self.p: A = None
        self.w: G = None
        self.s: G = None
        self.txt = txt

class E:
    def __init__(self, txt: str):
        self.r: A = None
        self.u: F = None
        self.x: F = None
        self.o: A = None
        self.p: D = None
        self.s: F = None
        self.txt = txt

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

class G:
    def __init__(self, txt: str):
        self.z: E = None
        self.s: A = None
        self.t: C = None
        self.r: E = None
        self.q: E = None
        self.txt = txt

d = A("d")
c = B("c")
h = C("h")
m = D("m")
a = E("a")
j = F("j")
g = G("g")
l = F("l")

d.p = h
d.r = j
c.s = d
h.y = m
h.p = a
h.q = c
h.u = c
h.o = g
m.z = h
m.p = d
m.w = g
m.s = g
a.r = d
a.o = d
a.u = j
a.x = j
a.s = j
a.p = m
j.r = d
g.z = a
g.r = a
g.q = a
g.s = d
g.t = h
l.r = d
assert d.r.r.p.o.t.q.txt == "c"