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

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

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

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

c = A("c")
i = B("i")
d = C("d")
n = D("n")
g = B("g")
j = D("j")
l = D("l")

c.s = d
c.y = d
c.t = d
c.x = l
i.p = c
i.u = g
d.q = g
n.y = d
n.p = c
n.t = j
n.z = i
g.p = c
g.u = i
j.y = d
j.p = c
j.t = l
j.z = i
l.y = d
l.p = c
l.t = j
l.z = i
assert j.p.x.p.x.y.txt == "
class A:
    def __init__(self, txt: str):
        self.s: C = None
        self.x: D = None
        self.y: C = None
        self.t: C = None
        self.txt = txt

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

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

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

c = A("c")
i = B("i")
d = C("d")
n = D("n")
g = B("g")
j = D("j")
l = D("l")

c.s = d
c.y = d
c.t = d
c.x = l
i.p = c
i.u = g
d.q = g
n.y = d
n.p = c
n.t = j
n.z = i
g.p = c
g.u = i
j.y = d
j.p = c
j.t = l
j.z = i
l.y = d
l.p = c
l.t = j
l.z = i
assert j.p.x.p.x.y.txt == "d"