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

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

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

g = A("g")
h = B("h")
i = C("i")
f = C("f")
l = C("l")
a = C("a")
d = B("d")
j = A("j")
c = A("c")
k = A("k")

g.r = i
h.x = j
h.q = f
i.x = j
i.p = h
i.z = l
f.x = k
f.p = d
f.z = l
l.x = j
l.p = d
l.z = f
a.x = j
a.p = d
a.z = i
d.x = g
d.q = f
j.r = l
c.r = l
k.r = i
assert i.x.r.p.q.p.txt == "
class A:
    def __init__(self, txt: str):
        self.r: C = None
        self.txt = txt

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

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

g = A("g")
h = B("h")
i = C("i")
f = C("f")
l = C("l")
a = C("a")
d = B("d")
j = A("j")
c = A("c")
k = A("k")

g.r = i
h.x = j
h.q = f
i.x = j
i.p = h
i.z = l
f.x = k
f.p = d
f.z = l
l.x = j
l.p = d
l.z = f
a.x = j
a.p = d
a.z = i
d.x = g
d.q = f
j.r = l
c.r = l
k.r = i
assert i.x.r.p.q.p.txt == "d"